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
Use create_upper_paths_hook for hypertable insert plan modifications #904
Use create_upper_paths_hook for hypertable insert plan modifications #904
Conversation
6b7a0e8
to
afd9ac2
Compare
Codecov Report
@@ Coverage Diff @@
## master #904 +/- ##
==========================================
- Coverage 91.25% 91.22% -0.04%
==========================================
Files 80 79 -1
Lines 9242 9227 -15
==========================================
- Hits 8434 8417 -17
- Misses 808 810 +2
Continue to review full report at Codecov.
|
dcb24d3
to
18b6c77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments. But I feel I should point out that now we are doing manipulation for each path where before we did it for each plan (and there are more paths than plans). This is probably the right thing to do anyway but thought I'd point out this potential downside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I left two minor comments.
d6e553f
to
fccce29
Compare
This change refactors how we do planner modifications to insert data into a hypertable. Instead of altering the finished plan tree produced by the standard planner, we now use the create_upper_paths_hook to do these modifications at the path stage during planning. Apart from being a cleaner, and arguably more principled, way of doing plan modifications, it also gives us better ability to modify plan state during planning since the hook happens during the normal planner run and not after. For instance, our CustomScan insert plan is now created using a callback that has access to the PlannerInfo data, which will be useful when planning, e.g., foreign queries using the foreign data wrapper API.
fccce29
to
995e864
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving. At some point we might consider just using our own node instead of wrapping modifyTable (to allow better re-use with the copy code). But I think that's a separate project.
Index rti = lfirst_int(lc_rel); | ||
RangeTblEntry *rte = planner_rt_fetch(rti, root); | ||
|
||
ht = ts_hypertable_cache_get_entry(hcache, rte->relid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to add a check here that we are always talking about the same hypertable here... That we aren't somehow mixing hypertables.
Hi @erimatnor, I came across this PR while trying to find a solution for HA TimescaleDB(link). I have a HA postgres cluster setup using Patroni. I would like to have a HA TimescaleDB on top of it. I know that it requires streaming replication for this use. How do I make it highly available and fail safe? Basic solution that comes to my mind is running two Timescale DB instances and then using HA Proxy over it. What do you think about it? Is there any other way to do it? |
This change refactors how we do planner modifications to insert data
into a hypertable. Instead of altering the finished plan tree produced
by the standard planner, we now use the create_upper_paths_hook to do
these modifications at the path stage during planning.
Apart from being a cleaner, and arguably more principled, way of doing
plan modifications, it also gives us better ability to modify plan
state during planning since the hook happens during the normal planner
run and not after. For instance, our CustomScan insert plan is now
created using a callback that has access to the PlannerInfo data,
which will be useful when planning, e.g., foreign queries using the
foreign data wrapper API.
NOTE: this is a change that we need for clustering.