spqr icon indicating copy to clipboard operation
spqr copied to clipboard

Improving perfomance for generating next sequence value.

Open xelavopelk opened this issue 5 months ago • 4 comments

Is your feature request related to a problem? Please describe. When we generate next sequence value for reference tables we need ask qdb every value now. It's hard for qdb(etcd) perfomance.

Describe the solution you'd like I propose every router instance will get range of values for autoincrement. Router ask for new pool only when it's pool ends. It helps avoid extra network interconnection with coordinator. Size of range may be different for a reference table. Size range pool may be configured for every reference table. System will work like now when range pool equals 1.

xelavopelk avatar Jul 25 '25 13:07 xelavopelk

We are short in time for real production client to start to use this feature, so I propose to incompatibly break all interfaces and rewrite NextVal qdb/protos method to use increment range value (so, without any qdb migration etc, just rewrite this).

reshke avatar Jul 26 '25 12:07 reshke

first part: https://github.com/pg-sharding/spqr/pull/1447

xelavopelk avatar Jul 28 '25 06:07 xelavopelk

MVP done here https://github.com/pg-sharding/spqr/pull/1452

xelavopelk avatar Aug 03 '25 09:08 xelavopelk

@xelavopelk says that ideally there should be a different increment step for each table, so the current implementation is only an MVP. Waiting for next PRs!

Denchick avatar Aug 12 '25 08:08 Denchick