New Feature Request

From: Bert Scalzo <bertscalzo2(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: New Feature Request
Date: 2020-05-26 00:53:40
Message-ID: CAFernC4mqBhF1qhH6fxDri8P=C912JBOyeSXDtcmLu4Tq1AV1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I am reposting this from a few months back (see below). I am not trying to
be a pest, just very motivated. I really think this feature has merit, and
if not generally worthwhile, I'd be willing to pay someone to code it for
me as I don't have strong enough C skills to modify the PostgreSQL code
myself. So anyone who might have such skills that would be interested,
please contact me: bertscalzo2(at)gmail(dot)com(dot)

MySQL has a really useful feature they call the query rewrite cache. The
optimizer checks incoming queries to see if a known better rewrite has been
placed within the query rewrite cache table. If one is found, the rewrite
replaces the incoming query before sending it to the execution engine. This
capability allows for one to fix poorly performing queries in 3rd party
application code that cannot be modified. For example, suppose a 3rd party
application contains the following inefficient query: SELECT COUNT(*) FROM
table WHERE SUBSTRING(column,1,3) = 'ABC'. One can place the following
rewrite in the query rewrite cache: SELECT COUNT(*) FROM table WHERE column
LIKE 'ABC%'. The original query cannot use an index while the rewrite can.
Since it's a 3rd party application there is really no other way to make
such an improvement. The existing rewrite rules in PostgreSQL are too
narrowly defined to permit such a substitution as the incoming query could
involve many tables, so what's needed is a general "if input SQL string
matches X then replace it with Y". This check could be placed at the
beginning of the parser.c code. Suggest that the matching code should first
check the string lengths and hash values before checking entire string
match for efficiency.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiro Ikeda 2020-05-26 01:16:19 Why don't you to document pg_shmem_allocations view's name list?
Previous Message Michael Paquier 2020-05-25 23:49:44 Re: WAL reader APIs and WAL segment open/close callbacks