Commit graph

13 commits

Author SHA1 Message Date
Julien Rouhaud
d102c8a640 Quote attribute names in deparsed index definition
Otherwise the emitted CREATE INDEX statement could be invalid.

Thanks to Oliver Rice for the report.
2024-04-17 23:11:23 +08:00
Julien Rouhaud
1a5766274d Check that hypopg_relation_size was given a hypothetical index oid.
And error out instead of returning 0 if that's not the case.

While at it, some iterating over the list of hypothetical indexes once we found
the wanted one.
2023-03-16 11:55:44 +08:00
Julien Rouhaud
f49d369bd6 Display hypothetical indexes on dropped tables in hypopg_list_indexes.
We could try to automatically remove such indexes by registering a relcache
callback, but this seems like an unlikely corner case so it doesn't seems worth
spending effort for that, accurately displaying the list of stored hypothetical
indexes should be enough.
2021-02-07 22:14:33 +08:00
Julien Rouhaud
2bd376d6bd Change the Oid generator.
To avoid locking on pg_class (required to safely call GetNewOidWithIndex or
similar) and to be usable on a standby node, use the oids unused in the
FirstBootstrapObjectId / FirstNormalObjectId range rather than real oids.  For
performance, always start with the biggest oid lesser than FirstNormalObjectId.
This way the loop to find an unused oid will only happens once a single backend
has created more than ~2.5k hypothetical indexes.

For people needing to have thousands of hypothetical indexes at the same time,
we also allow to use the initial implementation that relies on real oids, which
comes with all the limitations mentioned above, with the new
hypopg.use_real_oids GUC.
2021-01-22 19:56:06 +08:00
Julien Rouhaud
3131560b85 Change hypopg_list_indexes() to a view.
And while at schema-qualify relation names used in that view.
2021-01-22 18:55:48 +08:00
Julien Rouhaud
73d82eee94 Make tests more portable.
The estimated index size depends on the architecture, so just make
sure the code path is tested, without really caring of what the
estimated size is.  Thanks to Christoph Berg for the report.
2018-03-27 19:48:41 +02:00
Julien Rouhaud
79220f2c71 Fix NULL ordering for SORTBY_DESC case. Thanks to Andrew Kane for the
report and test case.
2017-09-05 06:45:31 +02:00
Julien Rouhaud
d2cfd7898f Add a hypopg_get_indexdef(oid) function 2016-11-16 23:49:27 +01:00
Julien Rouhaud
c05e2da4f7 Add support for hypothetical indexes on expression.
The estimation (size and cardinality) will probably always be very poor, the
postgres infrastructure get accurate informations by analyzing a real
index.  One consequence is that almost only Bitmap Index Scan will be
chosen by the planner.

Some simple and frequent expressions are explicitely handled (for now md5(),
lower() and uppser()), but it only impacts the estimated size, not the
selectivity.
2016-11-15 15:31:09 +01:00
Julien Rouhaud
022ac3396e Add regression test for expression indexes.
This has already been broken twice, make sure it won't happen again.
2016-06-07 20:10:04 +02:00
Julien Rouhaud
079a4f7610 Test hypopg.enabled GUC 2015-09-14 17:49:33 +02:00
Julien Rouhaud
1f211190fd Add some more tests 2015-09-03 19:02:32 +02:00
Julien Rouhaud
3bf0e6d118 Add some basic regression test. 2015-07-11 10:28:34 +02:00