On Sun, Jul 9, 2017 at 2:35 AM, Mark Rofail <markm.rof...@gmail.com> wrote:
> * What I am working on*
> - since we want to create an index on the referencing column, I am
> working on firing a 'CREATE INDEX' query programatically right after
> the 'CREATE TABLE' query
> - The problem I ran into is how to specify my Strategy (
> GinContainsElemStrategy) within the CREATE INDEX query. For
> example: CREATE INDEX ON fktable USING gin (fkcolumn array_ops)
> Where does the strategy number fit?
> - The patch is attached here, is the approach I took to creating an
> index programmatically, correct?
Could you, please, specify idea of what you're implementing in more
detail? AFACS, you're going to automatically create GIN indexes on FK
array columns. However, if we don't do this for regular columns, why
should we do for array columns? For me that sounds like a separate feature
which should be implemented for both regular and array FK columns.
Regarding your questions. If you need to create index supporting given
operator, you shouldn't take care about strategy number. Strategy number
makes sense only in opclass internals. You just need to specify opclass
which support your operator. In principle, you can find all of them in
pg_amop table. Alternatively you can just stick to GIN array_ops.
In general the approach you create index looks OK. It's OK to manually
create DDL node and execute it. As you can see, this is done in many other
places of backend code.
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company