Lessons about SQL (page 3)
The links, tools and tips our engineers and designers share with each other, one “today I learned” at a time.
- lessons shared
- 46
- people sharing
- 11
- database started in
- 2017










Tech Insights· github.com
pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL's contrib module pg_stat_statements
Shared by
Read on github.com- Postgresql
- SQL


Tech Insights· brianlikespostgres.com
The cost of a join and some benchmarks
Shared by
Read on brianlikespostgres.com- DB
- SQL


Tech Insights· adamj.eu
Must read if you need to know if multiple tables are empty in SQL. Small story: Once I had count check taking hours to run just to assert if the table was empty, this post explains how to fix it:
Shared by
Read on adamj.eu- Databases
- SQL

postgresql.org
Use
TRUNCATEwithRESTART IDENTITYto restart sequences as well:TRUNCATE TRUNCATE — empty a table or set of tables Synopsis TRUNCATE [ TABLE ] [ ONLY ] name [ …
Flávio Juvenal

Tech Insights· postgresql.org
Use
TRUNCATEwithRESTART IDENTITYto restart sequences as well:From postgresql.org
TRUNCATE TRUNCATE — empty a table or set of tables Synopsis TRUNCATE [ TABLE ] [ ONLY ] name [ …
Shared by
Read on postgresql.org- Postgresql
- SQL
Today I learned
If you have 4 parallel workers and need to process all rows from a SQL table, probably it's best to split the work with LIMIT...
If you have 4 parallel workers and need to process all rows from a SQL table, probably it's best to split the work with LIMIT/OFFSET into 4 parts and consume them with 4 tasks than to chose some smaller LIMIT/OFFSET and generate more than 4 tasks. OFFSET can get really slow and it doesn't build up speed when you make consecutive ones like OFFSET 1000, OFFSET 1100, OFFSET 1200, etc. In Python: limit = math.ceil(n_rows / n_workers) offsets = range(0, n_rows, limit)
Flávio Juvenal
Tech Insights
If you have 4 parallel workers and need to process all rows from a SQL table, probably it's best to split the work with LIMIT...
If you have 4 parallel workers and need to process all rows from a SQL table, probably it's best to split the work with LIMIT/OFFSET into 4 parts and consume them with 4 tasks than to chose some smaller LIMIT/OFFSET and generate more than 4 tasks. OFFSET can get really slow and it doesn't build up speed when you make consecutive ones like OFFSET 1000, OFFSET 1100, OFFSET 1200, etc. In Python:
limit = math.ceil(n_rows / n_workers) offsets = range(0, n_rows, limit)Shared by
- PostgreSQL
- SQL


Tech Insights· pgdash.io
Getting The Most Out Of Your PostgreSQL Indexes:
Shared by
Read on pgdash.io- DB
- Index
- Performance
- PostgreSQL
- SQL
Tech Insights· stackoverflow.com
Select first row in each GROUP BY group?
Shared by
Read on stackoverflow.com- DB
- PostgreSQL
- SQL
Tech Insights· stackoverflow.com
Django Subquery + Count:
Shared by
Read on stackoverflow.com- Django
- SQL


Tech Insights· blog.acolyer.org
Excellent article about how ORMs cause leaky abstractions that lead to performance issues and how fixing them is generally simple:
Shared by
Read on blog.acolyer.org- DB
- ORM
- Performance
- SQL
Tech Insights· stackoverflow.com
ORDER BY the IN value list:
Shared by
Read on stackoverflow.com- DB
- PostgreSQL
- SQL


Tech Insights· peterbe.com
Django 2.0 and Conditional Aggregations
Shared by
Read on peterbe.com- Django
- SQL

blog.heapanalytics.com
Postgres DB-level for-each with LATERAL:
This post walks through a conversion funnel analysis that wouldn’t be possible in PostgreSQL 9.2
Flávio Juvenal

Tech Insights· blog.heapanalytics.com
Postgres DB-level for-each with LATERAL:
From blog.heapanalytics.com
This post walks through a conversion funnel analysis that wouldn’t be possible in PostgreSQL 9.2
Shared by
Read on blog.heapanalytics.com- DB
- PostgreSQL
- SQL
Tech Insights· sqlrelease.com
On SQL Server, if LEFT OUTER JOIN or INNER JOIN is taking too long to run, try using CROSS APPLY or OUTER APPLY instead
Shared by
Read on sqlrelease.com- SQL
- Sqlserver

github.com
An instant JSON API for your SQLite databases:
An open source multi-tool for exploring and publishing data - simonw/datasette
Flávio Juvenal

Tech Insights· github.com
An instant JSON API for your SQLite databases:
From github.com
An open source multi-tool for exploring and publishing data - simonw/datasette
Shared by
Read on github.com- Python
- SQL
- Sqlite


Tech Insights· docs.djangoproject.com
Django 1.11 Subquery expressions: #subquery-expressions
Shared by
Read on docs.djangoproject.com- DB
- Django
- SQL
Book a call
Found it useful?
Let’s put it to work.
Tell us about your product and the problem in front of you. We’ll bring what we’ve learned on real projects.
Tell us about your product, and we’ll bring what we’ve learned.
Still prefer the good old email? Contact us



