Re: Extracting only the columns needed for a query - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Extracting only the columns needed for a query
Date
Msg-id CADkLM=cWt9JXk-YuSJbQbPzAzR2w0fmJsQh5zgxpkZx4z414ig@mail.gmail.com
Whole thread Raw
In response to Re: Extracting only the columns needed for a query  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
The thing that most approaches to this have fallen down on is triggers ---
that is, a trigger function might access columns mentioned nowhere in the
SQL text.  (See 8b6da83d1 for a recent example :-()  If you have a plan
for dealing with that, then ...

Well, if we had a trigger language that compiled to <something> at creation time, and that trigger didn't do any dynamic/eval code, we could store which attributes and rels were touched inside the trigger.

I'm not sure if that trigger language would be sql, plpgsql with a "compile" pragma, or maybe we exhume PSM, but it could have some side benefits:

  1. This same issue haunts any attempts at refactoring triggers and referential integrity, so narrowing the scope of what a trigger touches will help there too
  2. additional validity checks
  3. (this is an even bigger stretch) possibly a chance to combine multiple triggers into one statement, or combine mutliple row-based triggers into a statement level trigger

Of course, this all falls apart with one dynamic SQL or one SELECT *, but it would be incentive for the users to refactor code to not do things that impede trigger optimization.

pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: Re: Index Skip Scan
Next
From: Joe Conway
Date:
Subject: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and KeyManagement Service (KMS)