ankane / dexter

The automatic indexer for Postgres
MIT License
1.9k stars 47 forks source link

Excluding foreign tables #50

Closed nobelsmith closed 8 months ago

nobelsmith commented 8 months ago

I am trying to exclude foreign tables because I am getting a hypopg error when trying to create an index on them. However even if i pass them in to dexter using --exclude I get the same error.

For example: dexter --pg-stat-statements -d mydb --exclude foo.bar --log-sql --log-level debug2

results in:

[sql] SELECT * FROM hypopg_create_index('CREATE INDEX ON "foo"."bar" ("column")')
/opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:539:in `exec_params': ERROR:  hypopg: "bar" is not a table or materialized view (PG::InternalError)
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:539:in `block in execute'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:535:in `synchronize'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:535:in `execute'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:604:in `create_hypothetical_index'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:598:in `block (2 levels) in create_hypothetical_indexes_helper'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:597:in `permutation'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:597:in `block in create_hypothetical_indexes_helper'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:595:in `each'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:595:in `create_hypothetical_indexes_helper'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:219:in `create_hypothetical_indexes'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:99:in `process_queries'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/indexer.rb:32:in `process_stat_statements'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/client.rb:27:in `perform'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/lib/dexter/client.rb:9:in `start'
    from /opt/dexter/vendor/bundle/ruby/3.1.0/gems/pgdexter-0.5.2/exe/dexter:7:in `<top (required)>'
    from /opt/dexter/bin/dexter:17:in `load'
    from /opt/dexter/bin/dexter:17:in `<main>'

I am currently running postgres 16 on ubuntu 22.04 any help would be greatly appreciated!

ankane commented 8 months ago

Hi @nobelsmith, thanks for reporting! I'm not able to reproduce the issue with --exclude, but fixed the error with foreign tables in the commit above.