Alex Yarotsky (@alexyarotsky) 's Twitter Profile
Alex Yarotsky

@alexyarotsky

Tips on scaling #PostgreSQL and #rails | CTO at @Hubstaff

ID: 1080184880921747456

calendar_today01-01-2019 19:31:59

209 Tweet

419 Takipçi

168 Takip Edilen

Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

🔒 Keep #rails from modifying your database If your #database is read-only or externally managed, set database_tasks: false in database.yml. This prevents #rails from running migrations and schema changes.

🔒 Keep #rails from modifying your database

If your #database is read-only or externally managed, set database_tasks: false in database.yml. This prevents #rails from running migrations and schema changes.
Crunchy Data (@crunchydata) 's Twitter Profile Photo

The PostgreSQL CIS Benchmark for PostgreSQL 17 is out. This is a freely available, community driven, security checklist for Postgres. Crunchy Data is proud of our work with Center for Internet Security (CIS) on each new Postgres release. • All about the checklist:

The PostgreSQL CIS Benchmark for PostgreSQL 17 is out.

This is a freely available, community driven, security checklist for Postgres.

Crunchy Data is proud of our work with Center for Internet Security (CIS) on each new Postgres release.

• All about the checklist:
Crunchy Data (@crunchydata) 's Twitter Profile Photo

Postgres tip: Format your EXPLAIN plan as YAML. Looking through Postgres EXPLAIN plans can be tricky business. On one hand, its a great way to know what is happening with your queries and offers insights for performance improvement. On the other hand, it can feel like you’re

Postgres tip: Format your EXPLAIN plan as YAML. 

Looking through Postgres EXPLAIN plans can be tricky business. 

On one hand, its a great way to know what is happening with your queries and offers insights for performance improvement. On the other hand, it can feel like you’re
Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

🚀 Avoid N+1 queries in #rails with strict_loading Lazy loading is the default behavior in #activerecord, where associated records are fetched only when accessed. This can lead to N+1 queries, negatively affecting performance. strict_loading forces eager loading of

🚀 Avoid N+1 queries in #rails with strict_loading

Lazy loading is the default behavior in #activerecord, where associated records are fetched only when accessed. This can lead to N+1 queries, negatively affecting performance.

strict_loading forces eager loading of
Timescale (@timescaledb) 's Twitter Profile Photo

Not every database needs to be fast. Some need to relax. 😎🌴 Introducing pgsloth–the first totally chill database, perfect for those not-so-demanding apps. Queries run eventually. Maybe today. Maybe tomorrow. Who knows? 🦥 Try it today! Or don’t. No pressure. 😌 #pgsloth

Not every database needs to be fast. Some need to relax. 😎🌴

Introducing pgsloth–the first totally chill database, perfect for those not-so-demanding apps.

Queries run eventually. Maybe today. Maybe tomorrow. Who knows? 🦥

Try it today! Or don’t. No pressure. 😌

#pgsloth
Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

🗑️ Bulk delete records in #rails with delete_by Instead of chaining ".where(...).delete_all", use delete_by(...) for a cleaner shorthand. It behaves like delete_all—fast and skips callbacks. For callback-safe deletes, use destroy_by. #activerecord #database

🗑️ Bulk delete records in #rails with delete_by

Instead of chaining ".where(...).delete_all", use delete_by(...) for a cleaner shorthand.

It behaves like delete_all—fast and skips callbacks.

For callback-safe deletes, use destroy_by.

#activerecord #database
Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

🛠️ Use up_only in #rails migrations to skip logic on rollback Sometimes you need to run custom SQL during a #database migration, but not during rollback. That’s where up_only is useful. It runs code only when migrating up, keeping your rollbacks clean and safe.

🛠️ Use up_only in #rails migrations to skip logic on rollback

Sometimes you need to run custom SQL during a #database migration, but not during rollback. That’s where up_only is useful.

It runs code only when migrating up, keeping your rollbacks clean and safe.
Elizabeth Garrett Christensen (@sqlliz) 's Twitter Profile Photo

Postgres Meetup for All in a few hours will be meeting up to chat about connection pooling/failover with the new pgDog project (and pgCat). Join us! meetup.com/postgres-meetu…

Postgres Meetup for All in a few hours will be meeting up to chat about connection pooling/failover with the new pgDog project (and pgCat). Join us! meetup.com/postgres-meetu…
Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

🔗 Tell #activerecord your foreign key is a UUID Using UUIDs in #rails? Don’t forget to set type to uuid in your foreign keys. Rails defaults to bigint, which causes migration issues if your primary key is a UUID. Explicitly declare the type to keep things running smoothly.

🔗 Tell #activerecord your foreign key is a UUID

Using UUIDs in #rails? Don’t forget to set type to uuid in your foreign keys.

Rails defaults to bigint, which causes migration issues if your primary key is a UUID.

Explicitly declare the type to keep things running smoothly.
Alex Yarotsky (@alexyarotsky) 's Twitter Profile Photo

⚡️ 7 Performance Must-Do for Every #rails App ✅ Replace ".where.each" with ".find_each" to avoid loading everything into memory at once ✅ Use production-like data in dev to expose N+1 queries before your users do ✅ Pay attention to logs or use "rack-mini-profiler" to catch

Crunchy Data (@crunchydata) 's Twitter Profile Photo

Postgres users love Common Table Expressions (CTEs) because they make complex SQL easy to read, create, edit, and reuse. Simplicity – CTEs let you break a query into smaller logical chunks, with subqueries defined at the top of the query. It is almost like giving a query book

Postgres users love Common Table Expressions (CTEs) because they make complex SQL easy to read, create, edit, and reuse. 

Simplicity – CTEs let you break a query into smaller logical chunks, with subqueries defined at the top of the query. It is almost like giving a query book
Crunchy Data (@crunchydata) 's Twitter Profile Photo

Postgres vacuum is an essential process. For most folks, you just let autovacuum do its thing and you never have to worry about it. But for large and busy databases, you may need to keep tabs on vacuum and how it impacts your operations and do some manual tuning and vacuum. In

Postgres vacuum is an essential process. For most folks, you just let autovacuum do its thing and you never have to worry about it. But for large and busy databases, you may need to keep tabs on vacuum and how it impacts your operations and do some manual tuning and vacuum. 

In