Home > database >  Pg9.4 version USES gist or gin index leads to the CPU surge
Pg9.4 version USES gist or gin index leads to the CPU surge

Time:11-27

Background: due to historical reasons, a field is stored in the form of a comma when stored strings, like: a, b, c, the query need full fuzzy matching, and the whole will have multiple fuzzy matching or situation, i.e. to match keywords is a collection of currently pg_trgm plug-in has been installed, tested gin and gist index respectively, while the performance is very good, but under the high concurrency CPU soar quickly; And tried pg array matching, using the index of gin created above field function index, index form such as: gin (string_to_array (valid_groups, ', ')); Key query form, such as: array [' UGSG1911041C502M5W ', 'UG1811201ELR0J9C_', 'UG17103010CTDBEO_', 'UGSG1908131DH64C2F', 'UI1709212MG35TK', 'UGSG1909171EWS2HCP', 'UGSG2005061HZUK0CD', 'UGSG1908131DH64C1Z,
'UG1908131DH64C1V_', 'UGSG1909052OE7DXB', 'UGSG1908131DH64C21] & amp; &
String_to_array (valid_groups, ', ')


This way performance will be faster, but the CPU will continue to soar, the project has already had a gist + gist_trgm_ops practice, there is no problem, the adjustment of SQL due to the extremely complex, and also involves the union all temporarily unable to modify this part of the business logic, leading to an online CPU is soaring, ever tell bosses? Contact pg is not very long
  • Related