On Fri, Jan 27, 2023 at 11:59:47AM +0900, Michael Paquier wrote: > Using that, I can compile the following results for various cases (-O2 > and compute_query_id=on): > query | mode | iterations | avg_runtime_ns | > avg_jumble_ns > -------------------------+--------+------------+----------------+--------------- > begin | string | 50000000 | 4.53116 | > 4.54 > begin | jumble | 50000000 | 30.94578 | > 30.94 > commit | string | 50000000 | 4.76004 | > 4.74 > commit | jumble | 50000000 | 31.4791 | > 31.48 > create table 1 column | string | 50000000 | 7.22836 | > 7.08 > create table 1 column | jumble | 50000000 | 152.10852 | > 151.96 > create table 5 columns | string | 50000000 | 12.43412 | > 12.28 > create table 5 columns | jumble | 50000000 | 352.88976 | > 349.1 > create table 20 columns | string | 5000000 | 49.591 | > 48.2 > create table 20 columns | jumble | 5000000 | 2272.4066 | > 2271 > drop table 1 column | string | 50000000 | 6.70538 | > 6.56 > drop table 1 column | jumble | 50000000 | 50.38 | > 50.24 > drop table 5 columns | string | 50000000 | 6.88256 | > 6.74 > drop table 5 columns | jumble | 50000000 | 50.02898 | > 49.9 > SET work_mem | string | 50000000 | 7.28752 | > 7.28 > SET work_mem | jumble | 50000000 | 91.66588 | > 91.64 > (16 rows)
Just to close the loop here, I have done more measurements to compare the jumble done for some DMLs and some SELECTs between HEAD and the patch (forgot to post some last Friday). Both methods show comparable results: query | mode | iterations | avg_runtime_ns | avg_jumble_ns ----------------------+--------+------------+----------------+--------------- insert table 10 cols | master | 50000000 | 377.17878 | 377.04 insert table 10 cols | jumble | 50000000 | 409.47924 | 409.34 insert table 20 cols | master | 50000000 | 692.94924 | 692.8 insert table 20 cols | jumble | 50000000 | 710.0901 | 709.96 insert table 5 cols | master | 50000000 | 232.44308 | 232.3 insert table 5 cols | jumble | 50000000 | 253.49854 | 253.36 select 10 cols | master | 50000000 | 449.13608 | 383.36 select 10 cols | jumble | 50000000 | 491.61912 | 323.86 select 5 cols | master | 50000000 | 277.477 | 277.46 select 5 cols | jumble | 50000000 | 323.88152 | 323.86 (10 rows) The averages are in ns, so the difference does not bother me much. There may be some noise mixed in that ;) (Attached is the tweak I have applied on HEAD to get some numbers.) -- Michael
diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c index 16084842a3..c66090bde3 100644 --- a/src/backend/nodes/queryjumblefuncs.c +++ b/src/backend/nodes/queryjumblefuncs.c @@ -101,10 +101,14 @@ CleanQuerytext(const char *query, int *location, int *len) JumbleState * JumbleQuery(Query *query, const char *querytext) { +#define MAX_QUERY_COMPUTE 50000000 + JumbleState *jstate = NULL; Assert(IsQueryIdEnabled()); + elog(WARNING, "start JumbleQuery"); + if (query->utilityStmt) { query->queryId = compute_utility_query_id(querytext, @@ -114,18 +118,26 @@ JumbleQuery(Query *query, const char *querytext) else { jstate = (JumbleState *) palloc(sizeof(JumbleState)); - - /* Set up workspace for query jumbling */ jstate->jumble = (unsigned char *) palloc(JUMBLE_SIZE); - jstate->jumble_len = 0; jstate->clocations_buf_size = 32; jstate->clocations = (LocationLen *) palloc(jstate->clocations_buf_size * sizeof(LocationLen)); - jstate->clocations_count = 0; - jstate->highest_extern_param_id = 0; - /* Compute query ID and mark the Query node with it */ - JumbleQueryInternal(jstate, query); + for (int i = 0; i < MAX_QUERY_COMPUTE ; i++) + { + /* Set up workspace for query jumbling */ + memset(jstate->jumble, 0, sizeof(JUMBLE_SIZE)); + jstate->jumble_len = 0; + jstate->clocations_buf_size = 32; + memset(jstate->clocations, 0, + jstate->clocations_buf_size * sizeof(LocationLen)); + + jstate->clocations_count = 0; + jstate->highest_extern_param_id = 0; + + /* Compute query ID and mark the Query node with it */ + JumbleQueryInternal(jstate, query); + } query->queryId = DatumGetUInt64(hash_any_extended(jstate->jumble, jstate->jumble_len, 0)); @@ -138,6 +150,8 @@ JumbleQuery(Query *query, const char *querytext) query->queryId = UINT64CONST(1); } + elog(WARNING, "end JumbleQuery"); + return jstate; }
signature.asc
Description: PGP signature