RE: Index Skip Scan (new UniqueKeys)

From: Floris Van Nee <florisvannee(at)Optiver(dot)com>
To: Floris Van Nee <florisvannee(at)Optiver(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, "Dilip Kumar" <dilipbalaut(at)gmail(dot)com>
Subject: RE: Index Skip Scan (new UniqueKeys)
Date: 2020-07-12 22:18:26
Message-ID: a71e7d0a92d3461fa937e63f536c39ad@opammb0561.comp.optiver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> I've attached the first two unique-keys patches (v9, 0001, 0002)), your
> patches, but rebased on v9 of unique keys (0003-0006) + a diff patch (0007)
> that applies my suggested changes on top of it.
>

I just realized there's another thing that looks a bit strange too. From reading the thread, I thought it should be the case that in create_distinct_paths, it is checked whether the uniqueness in the unique_pathlist matches the uniqueness that is needed by the query.
This means that I think what it should be comparing is this:
- The generated index path should have some path-level unique keys set
- The path-level unique keys must be at least as strict as the path-level unique keys. Eg. if path-level is unique on (a), then query-level must be (a), or possibly (a,b).

I've changed the patch to compare the path-level keys (set in create index path) with the query-level keys in create_distinct_path. Currently, I don't think the previous implementation was an actual issue leading to incorrect queries, but it would be causing problems if we tried to extend the uniqueness for distinct to join rels etc.

One question about the unique keys - probably for Andy or David: I've looked in the archives to find arguments for/against using Expr nodes or EquivalenceClasses in the Unique Keys patch. However, I couldn't really find a clear answer about why the current patch uses Expr rather than EquivalenceClasses. At some point David mentioned "that probably Expr nodes were needed rather than EquivalenceClasses", but it's not really clear to me why. What were the thoughts behind this?

-Floris

Attachment Content-Type Size
0001-Introduce-RelOptInfo-notnullattrs-attribute.patch application/octet-stream 4.8 KB
0002-Introduce-UniqueKey-attributes-on-RelOptInfo-struct.patch application/octet-stream 58.6 KB
0003-Extend-UniqueKeys.patch application/octet-stream 13.0 KB
0004-Index-skip-scan.patch application/octet-stream 38.4 KB
0005-Btree-implementation-of-skipping.patch application/octet-stream 40.0 KB
0006-Index-skip-scan-documentation.patch application/octet-stream 4.6 KB
0007-planner-fixes.patch application/octet-stream 14.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2020-07-12 22:36:02 Re: [PATCH] Performance Improvement For Copy From Binary Files
Previous Message Daniel Gustafsson 2020-07-12 20:50:55 Re: Libpq support to connect to standby server as priority