Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The select is too slowly #22

Closed
houzi1099857978 opened this issue Mar 11, 2021 · 5 comments
Closed

The select is too slowly #22

houzi1099857978 opened this issue Mar 11, 2021 · 5 comments

Comments

@houzi1099857978
Copy link

I put 100,000 rows data to elasticsearch,when I select 1 row by id through foreign table,it took 222 second, I wander is it fetch all data from elasticsearch to postgres and then filter the data?

@matthewfranglen
Copy link
Owner

matthewfranglen commented Mar 11, 2021

Ideally https://github.com/matthewfranglen/postgres-elasticsearch-fdw/blob/master/pg_es_fdw/__init__.py#L107 would use the rowid column if it is in the where clause, but it does not. Currently I just evaluate the where clause column, so you can make it fast if you should use that. Something like:

select * from test_es where query = '_id:1';

@houzi1099857978
Copy link
Author

https://github.com/matthewfranglen/postgres-elasticsearch-fdw/blob/master/pg_es_fdw/__init__.py#L107 should use the rowid column if it is in the where clause. Currently I just evaluate the where clause column, so you can make it fast if you should use that. Something like:

select * from test_es where query = '_id:1';

Thanks,it is faster by using query fetch data

@ghost
Copy link

ghost commented Apr 16, 2021

Hello,

I was trying to perform the query from Postgres to elasticsearch using "query" as shown above. But it was throwing me an error saying...

postgres=# select * from articles_es where query = '_id:1';
ERROR:  COUNT for /index1 failed: Expecting value: line 1 column 1 (char 0)

Here are the details of how I created the foreign table (providing info on a high level):

CREATE FOREIGN TABLE articles_es
    (
        id TEXT,
        query TEXT,
        ....
    )
SERVER multicorn_es
OPTIONS
    (
        host 'elasticsearch',
        port '9200',
        index 'article-index',
        type 'article',
        rowid_column 'id',
        query_column 'query',
        query_dsl 'false',
        refresh 'false',
        complete_returning 'false',
        timeout '20',
        username 'elastic',
        password 'elastic'
    )
;

Any suggestions, please.

@matthewfranglen
Copy link
Owner

The response that is being received by the client is not json. This is really a separate issue so I've opened it as another issue: #26

@matthewfranglen
Copy link
Owner

I've opened #27 to track the problem that this ticket originally reports. Since this ticket has lost focus I am closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants