Re: [PATCH] Generic type subscription

Dmitry Dolgov <9erthalion6@gmail.com>

From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Artur Zakirov <a.zakirov@postgrespro.ru>
Cc: Victor Wagner <vitus@wagner.pp.ru>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2016-11-13T17:52:00Z
Lists: pgsql-hackers

Attachments

Hi

Sorry for late reply and thank you for the feedback (especially about the
problem with performance).

> There is another occurrences of "subscription" including file names

Fixed.

> we have performance degradation of SELECT queries

Yes, I figured it out. The main problem was about type info lookups, some of
them were made for each data extraction operation, which is unnecessary.
Here are results on my machine:

with the fixed version of patch

=# explain analyze select a[1], b[1][1][1] from test;
                                                 QUERY PLAN

------------------------------------------------------------------------------------------------------------
 Seq Scan on test  (cost=0.00..5286.00 rows=100000 width=6) (actual
time=0.950..48.370 rows=100000 loops=1)
 Planning time: 0.054 ms
 Execution time: 51.859 ms
(3 rows)

and without the patch

=# explain analyze select a[1], b[1][1][1] from test;

                                                 QUERY PLAN

------------------------------------------------------------------------------------------------------------
 Seq Scan on test  (cost=0.00..5286.00 rows=100000 width=6) (actual
time=3.443..43.452 rows=100000 loops=1)
 Planning time: 0.117 ms
 Execution time: 46.875 ms
(3 rows)

It's still slightly slower because of all new logic aroung subscripting
operation, but not that much.

Commits

  1. Throw error when assigning jsonb scalar instead of a composite object

  2. Filling array gaps during jsonb subscripting

  3. Implementation of subscripting for jsonb

  4. Support subscripting of arbitrary types, not only arrays.

  5. Remove obsoleted code relating to targetlist SRF evaluation.

  6. Include <sys/select.h> where needed