Performance Tuning: Create index for boolean column

For a query like this, a partial index covering only unsynced rows would serve best. CREATE INDEX ON tbl (id) WHERE sync_done = FALSE; However, for a use case like this, other synchronization methods may be preferable to begin with: Have a look at LISTEN / NOTIFY. Or use a trigger in combination with dblink … Read more

When will a FAST_FORWARD cursor have a work table (and is this something to avoid)?

Just a hunch, but normally a TOP-ORDER BY requires SQL Server to buffer the result in some way (either the index scan’s result or indeed the entire result in a temp structure, or anything in between). One could argue that for cursors this is also necessary even when ordering by the primary key (as in … Read more

MySQL | REGEXP VS Like

I’ve tried it out on MySQL 8.0.13 and compared LIKE vs REGEXP on a table with 1M+ rows on a column with an index: SELECT * FROM table WHERE column LIKE ‘%foobar%’; Query took 10.0418 seconds. SELECT * FROM table WHERE REGEXP_LIKE(column, ‘foobar’); Query took 11.0742 seconds. LIKE performance is faster. If you can get … Read more

Why do spring/hibernate read-only database transactions run slower than read-write?

Why do spring/hibernate read-only database transactions run slower than read-write? <tldr> The short answer to question #1 was that hibernate starts off a @Transaction(readOnly = true) session with a set session.transaction.read.only synchronous JDBC call and ends with a set session.transaction.read.write call. These calls are not sent when doing read-write calls which is why read-only calls … Read more

BerkeleyDB Concurrency

It depends on what kind of application you are building. Create a representative test scenario, and start hammering away. Then you will know the definitive answer. Besides your use case, it also depends on CPU, memory, front-side bus, operating system, cache settings, etcetera. Seriously, just test your own scenario. If you need some numbers (that … Read more

Performance difference between UUID, CHAR, and VARCHAR in PostgreSql table?

Use uuid. PostgreSQL has the native type for a reason. It stores the uuid internally as a 128-bit binary field. Your other proposed options store it as hexadecimal, which is very inefficient in comparison. Not only that, but: uuid does a simple bytewise sort for ordering. text, char and varchar consider collations and locales, which … Read more