init_sequence spill to hash table - Mailing list pgsql-hackers

From David Rowley
Subject init_sequence spill to hash table
Date
Msg-id CAApHDvpAczv3XjmRsa9HJ4YEVSKiqX0QTaQew7-DoFKsuzeO5Q@mail.gmail.com
Whole thread Raw
Responses Re: init_sequence spill to hash table
Re: init_sequence spill to hash table
List pgsql-hackers
Here http://www.postgresql.org/message-id/24278.1352922571@sss.pgh.pa.us there was some talk about init_sequence being a bottleneck when many sequences are used in a single backend.

The attached I think implements what was talked about in the above link which for me seems to double the speed of a currval() loop over 30000 sequences. It goes from about 7 seconds to 3.5 on my laptop.

I thought I would post the patch early to see if this is actually wanted before I do too much more work on it.

My implementation maintains using the linear list for sequences up to a defined threshold (currently 32) then it moves everything over to a hashtable and free's off the list.

A more complete solution would contain regression tests to exercise the hash table code. 

I know there is a desire to move sequences over to a single table still, but I see this as a separate patch and storing current values in a hash table for each backend should still be a win even if/when the single table stuff gets implemented.

Regards

David Rowley

Attachment

pgsql-hackers by date:

Previous
From: "Colin 't Hart"
Date:
Subject: [PATCH] Sort contents entries in reference documentation
Next
From: Haribabu kommi
Date:
Subject: Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])