News for hackers. Stuff that matters.
Re:Operating an Entire Company on a Minimal Two-Core Postgre... by dkjaudyeqooe on Thursday November 16, 2023 @01:24PM (#38293369)
> Performance optimization has become a lost art.

It's really not very hard, basically add indexes wherever lookups are done but don't go overboard, especially with tables that see a lot of inserts. The DB will tell you what it's doing if you ask, it's all easily investigated. If your joins resist optimisation your data structure is probably off.

> I won't even touch on proper design, which requires someone with significant database expertise from the get-go

In more extreme cases this is true, but a few basic principles and an understanding of databases will get you 95% of the way there and is quite intuitive. Something as basic as "don't copy data around, each individual entity exists in one place, and use its key to refer to it otherwise" will help enormously.

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by alex7734 on Thursday November 16, 2023 @01:50PM (#38293666)
> It's really not very hard, basically add indexes

It's really not but you'd be surprised how many people don't know the basics of how indexes work. I've had people tell me that their queries couldn't be optimized further because "they had already added an index for every column of the table".

It doesn't help that SQL, by design, hides the actual algorithm doing the data access from the users while simultaneously relying on them to add indexes to achieve performance, which is in my humble opinion the worst mistake of SQL.

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by corytheboyd on Thursday November 16, 2023 @03:20PM (#38294913)
I love to ask this very simple question in interviews: if a database index makes queries faster, why not add an index for every column on a table?

I want them to say “the heck are you talking about, because that’s not how anything works?”… it does trip some people up though that just legitimately don’t understand what’s happening.

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by ako on Thursday November 16, 2023 @03:23PM (#38294951)
That is not a SQL mistake, but an implementation choice. Most modern databases can determine where indexes should be added, and add these automatically. E.g.: https://www.oracle.com/news/connect/oracle-database-automati...
Re:Operating an Entire Company on a Minimal Two-Core Postgre... by akoboldfrying on Thursday November 16, 2023 @06:38PM (#38297223)
This is news to me. Can any other DBs do this?

(I only skimmed -- far too much "Joan explains that" to signal ratio.)

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by ako on Friday November 17, 2023 @01:37AM (#38300287)
Re:Operating an Entire Company on a Minimal Two-Core Postgre... by sharadov on Thursday November 23, 2023 @02:44PM (#38396695)
Not for postgres or mysql.
Re:Operating an Entire Company on a Minimal Two-Core Postgre... by sgarland on Thursday November 16, 2023 @06:33PM (#38297177)
> The DB will tell you what it's doing if you ask, it's all easily investigated.

It will tell you _what_ it's doing, but not _why_ it's doing it. Unraveling the mysteries of the query planner is a dark art that is still firmly in the realm of graybeards.

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by sharadov on Thursday November 23, 2023 @02:47PM (#38396729)
Exactly and that's where it gets hairy and you need deep expertise.
Re:Operating an Entire Company on a Minimal Two-Core Postgre... by xarope on Thursday November 16, 2023 @08:14PM (#38297993)
As a former DBA and optimization expert, the more appropriate response is NOT "add more indexes", but rather to profile and analyze your query plans first, then make decisions off those; e.g. a long running query might be causing deadlocks, another query can be optimize with different joins or ctes, etc.

Adding indexes can increase I/O time (more writes), increase DB file sizes (more stuff to store) etc, which are not inconsequential. Sometimes it's also as simple as moving indexes to a tablespace stored on an SSD.

Re:Operating an Entire Company on a Minimal Two-Core Postgre... by ndriscoll on Friday November 17, 2023 @12:48PM (#38307156)
Rounding out the end of 2023 where a 15 TB pcie gen 4 drive is $1800, it's hard for me to accept the fact that SSD storage for databases (or at least the indexes) isn't just a given.