Hi, hackers
I made the final version tablesample patch. It is implementing SYSTEM and BERNOULLI sample method, which is basically "feature-complete". The regression test is also included in this patch.
There is an wiki documentation on https://wiki.postgresql.org/wiki/TABLESAMPLE_Implementation. The detail about this patch and this project is all included in this documentation.
The pgbench test result below:
Without patch:transaction type: SELECT only
scaling factor: 10
query mode: simple
duration: 30 s
number of clients: 2
number of threads: 2
number of transactions actually processed: 304857
tps = 10161.803463 (including connections establishing)
tps = 10162.963554 (excluding connections establishing)
number of clients: 4
number of threads: 2
number of transactions actually processed: 245072
tps = 8168.796552 (including connections establishing)
tps = 8173.947876 (excluding connections establishing)
number of clients: 8
number of threads: 2
number of transactions actually processed: 218426
tps = 7280.624465 (including connections establishing)
tps = 7284.863386 (excluding connections establishing)
scaling factor: 10
number of clients: 16
number of threads: 2
number of transactions actually processed: 199204
tps = 6636.427331 (including connections establishing)
tps = 6650.783233 (excluding connections establishing)
scaling factor: 10
number of clients: 32
number of threads: 2
number of transactions actually processed: 186793
tps = 6221.025810 (including connections establishing)
tps = 6238.904071 (excluding connections establishing)
With Patch:
number of clients: 2
number of threads: 2
number of transactions actually processed: 329926
tps = 10997.232742 (including connections establishing)
tps = 10998.712762 (excluding connections establishing)
number of clients: 4
number of threads: 2
number of transactions actually processed: 261993
tps = 8732.875565 (including connections establishing)
tps = 8735.013550 (excluding connections establishing)
number of clients: 8
number of threads: 2
number of transactions actually processed: 203579
tps = 6785.601601 (including connections establishing)
tps = 6788.043016 (excluding connections establishing)
number of clients: 16
number of threads: 2
number of transactions actually processed: 190773
tps = 6354.824262 (including connections establishing)
tps = 6361.348206 (excluding connections establishing)
number of clients: 32
number of threads: 2
number of transactions actually processed: 190801
tps = 6353.821626 (including connections establishing)
tps = 6380.813409 (excluding connections establishing)
Thanks and Best Regards
Huang Qi Victor
Computer Science of National University of Singapore