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

where, limit, order statements are not forwarded to CH #4

Open
kosjak1 opened this issue Jun 5, 2018 · 2 comments
Open

where, limit, order statements are not forwarded to CH #4

kosjak1 opened this issue Jun 5, 2018 · 2 comments

Comments

@kosjak1
Copy link

kosjak1 commented Jun 5, 2018

Hello! I have installed your Clickhouse FDW and got problems.
Example:

Query in psql: select * from clickhouse.vast_tracking where date=current_date order by dt desc limit 10;

Query in CH processlist: SELECT intDiv(2333294099, uniqCombined(vast_tracking_id)) AS vast_tracking_id, intDiv(2333294099, uniqCombined(ip)) AS ip, intDiv(2333294099, uniqCombined(date)) AS date, intDiv(2333294099, uniqCombined(key)) AS key, intDiv(2333294099, uniqCombined(action)) AS action, intDiv(2333294099, uniqCombined(url)) AS url, intDiv(2333294099, uniqCombined(referrer)) AS referrer, intDiv(2333294099, uniqCombined(country)) AS country, intDiv(2333294099, uniqCombined(banner)) AS banner, intDiv(2333294099, uniqCombined(year)) AS year, intDiv(2333294099, uniqCombined(month)) AS month, intDiv(2333294099, uniqCombined(day)) AS day, intDiv(2333294099, uniqCombined(hour)) AS hour, intDiv(2333294099, uniqCombined(uuid)) AS uuid, intDiv(2333294099, uniqCombined(sky_uuid)) AS sky_uuid, intDiv(2333294099, uniqCombined(creative_id)) AS creative_id, intDiv(2333294099, uniqCombined(revenue)) AS revenue, intDiv(2333294099, uniqCombined(in_price)) AS in_price, intDiv(2333294099, uniqCombined(wm_percent)) AS wm_percent, intDiv(2333294099, uniqCombined(profit)) AS profit, intDiv(2333294099, uniqCombined(dt)) AS dt, intDiv(2333294099, uniqCombined(vt)) AS vt, intDiv(2333294099, uniqCombined(advert_id)) AS advert_id, intDiv(2333294099, uniqCombined(site_url)) AS site_url, intDiv(2333294099, uniqCombined(campaign_name)) AS campaign_name FROM default.vast

As you can see - where, order by, limit are not passed, so CH is trying to obtain all data from table and push it to Postgres, this table have billions of records and it will take a long time to pass data.

@ishirav
Copy link

ishirav commented Jun 5, 2018

Hi,

I believe postgres is not pushing the condition to the FDW. The documentation states that: "WHERE clauses are not sent to the remote server unless they use only data types, operators, and functions that are built-in or belong to an extension that's listed in the foreign server's extensions option. Operators and functions in such clauses must be IMMUTABLE as well."
In this case, I'm guessing current_date is mutable and therefore the condition is not pushed down to the FDW. Try changing the current_date to a specific fixed date, and see if that makes a difference.

@kosjak1
Copy link
Author

kosjak1 commented Jun 6, 2018

I've tried this query: select * from clickhouse.vast_tracking where date='2018-06-06' order by dt desc limit 10;

But no luck, CH receives query without where parameters...

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