pgsql: Extended statistics on expressions

2021-03-26 Thread Tomas Vondra
Extended statistics on expressions Allow defining extended statistics on expressions, not just just on simple column references. With this commit, expressions are supported by all existing extended statistics kinds, improving the same types of estimates. A simple example may look like this: CR

pgsql: Reduce duration of stats_ext regression tests

2021-03-26 Thread Tomas Vondra
Reduce duration of stats_ext regression tests The regression tests of extended statistics were taking a fair amount of time, due to using fairly large data sets with a couple thousand rows. So far this was fine, but with tests for statistics on expressions the duration would get a bit excessive.

pgsql: Fix ndistinct estimates with system attributes

2021-03-26 Thread Tomas Vondra
Fix ndistinct estimates with system attributes When estimating the number of groups using extended statistics, the code was discarding information about system attributes. This led to strange situation that SELECT 1 FROM t GROUP BY ctid; could have produced higher estimate (equal to pg_class

pgsql: Fix ndistinct estimates with system attributes

2021-03-26 Thread Tomas Vondra
Fix ndistinct estimates with system attributes When estimating the number of groups using extended statistics, the code was discarding information about system attributes. This led to strange situation that SELECT 1 FROM t GROUP BY ctid; could have produced higher estimate (equal to pg_class

pgsql: Fix ndistinct estimates with system attributes

2021-03-26 Thread Tomas Vondra
Fix ndistinct estimates with system attributes When estimating the number of groups using extended statistics, the code was discarding information about system attributes. This led to strange situation that SELECT 1 FROM t GROUP BY ctid; could have produced higher estimate (equal to pg_class

pgsql: Fix ndistinct estimates with system attributes

2021-03-26 Thread Tomas Vondra
Fix ndistinct estimates with system attributes When estimating the number of groups using extended statistics, the code was discarding information about system attributes. This led to strange situation that SELECT 1 FROM t GROUP BY ctid; could have produced higher estimate (equal to pg_class

pgsql: Fix ndistinct estimates with system attributes

2021-03-26 Thread Tomas Vondra
Fix ndistinct estimates with system attributes When estimating the number of groups using extended statistics, the code was discarding information about system attributes. This led to strange situation that SELECT 1 FROM t GROUP BY ctid; could have produced higher estimate (equal to pg_class

pgsql: Merge similar algorithms into roles_is_member_of().

2021-03-26 Thread Noah Misch
Merge similar algorithms into roles_is_member_of(). The next commit would have complicated two or three algorithms, so take this opportunity to consolidate. No functional changes. Reviewed by John Naylor. Discussion: https://postgr.es/m/20201228043148.ga1053...@rfd.leadboat.com Branch -- m

pgsql: Add "pg_database_owner" default role.

2021-03-26 Thread Noah Misch
Add "pg_database_owner" default role. Membership consists, implicitly, of the current database owner. Expect use in template databases. Once pg_database_owner has rights within a template, each owner of a database instantiated from that template will exercise those rights. Reviewed by John Nayl

pgsql: Fix alignment in BRIN minmax-multi deserialization

2021-03-26 Thread Tomas Vondra
Fix alignment in BRIN minmax-multi deserialization The deserialization failed to ensure correct alignment, as it assumed it can simply point into the serialized value. The serialization however ignores alignment and copies just the significant bytes in order to make the result as small as possible

pgsql: BRIN minmax-multi indexes

2021-03-26 Thread Tomas Vondra
BRIN minmax-multi indexes Adds BRIN opclasses similar to the existing minmax, except that instead of summarizing the page range into a single [min,max] range, the summary consists of multiple ranges and/or points, allowing gaps. This allows more efficient handling of data with poor correlation to

pgsql: BRIN bloom indexes

2021-03-26 Thread Tomas Vondra
BRIN bloom indexes Adds a BRIN opclass using a Bloom filter to summarize the range. Indexes using the new opclasses allow only equality queries (similar to hash indexes), but that works fine for data like UUID, MAC addresses etc. for which range queries are not very common. This also means the ind

pgsql: Support the old signature of BRIN consistent function

2021-03-26 Thread Tomas Vondra
Support the old signature of BRIN consistent function Commit a1c649d889 changed the signature of the BRIN consistent function by adding a new required parameter. Treating the parameter as optional, which would make the change backwards incompatibile, was rejected with the justification that there

pgsql: Remove unnecessary pg_amproc BRIN minmax entries

2021-03-26 Thread Tomas Vondra
Remove unnecessary pg_amproc BRIN minmax entries The BRIN minmax opclasses included amproc entries with mismatching left and right types, but those happen to be unnecessary. The opclasses only need cross-type operators, not cross-type support procedures. Discovered when trying to define equivalen

RE: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode

2021-03-26 Thread tsunakawa.ta...@fujitsu.com
From: Robert Haas > On Wed, Mar 24, 2021 at 12:48 AM Andres Freund > wrote: > > Although this specific hack doesn't seem too terrible to me. If you > > execute a parallel insert the likelihood to end up not needing an xid is > > pretty low. Implementing it concurrently does seem like it'd end up