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

Revert index scan #247

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Revert index scan #247

merged 4 commits into from
Oct 7, 2024

Conversation

mkaruza
Copy link
Collaborator

@mkaruza mkaruza commented Oct 3, 2024

Reverting index scan feature as explained in #183. Removed query planning from execution.

Three commits that should not be squashed when merging.

Fixes #183

@mkaruza mkaruza requested a review from JelteF October 3, 2024 13:44
@@ -36,7 +35,7 @@ PostgresTable::PopulateColumns(CreateTableInfo &info, Oid relid, Snapshot snapsh
auto tupleDesc = RelationGetDescr(rel);

if (!tupleDesc) {
elog(ERROR, "Failed to get tuple descriptor for relation with OID %u", relid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably a good change, but let's move it to a separate PR. It's nice to keep behavioral and refactoring changes separate, both for review and possible future git revert.


private:
Path *path;
PlannerInfo *planner_info;
Copy link
Collaborator

@JelteF JelteF Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the PlannerInfo to be passed into DuckDB now at all? i.e. I think we were only using it to choose between sequence scan and index scan, so I think we can get rid of storing it in the "postgres_state" key of context->registered_state.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, I think that might also remove the entire need for PostgresContextState, I believe m_rtables and m_needed_columns as well as m_query_string are not used ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's indeed the case, let's remove those too. That simplifies stuff a lot.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also fine with doing that in a follow up PR btw.

@mkaruza mkaruza force-pushed the revert-index-scans branch 2 times, most recently from e0b0b14 to 5ac446b Compare October 4, 2024 08:41
duck_type.ToString().c_str());
}

RelationClose(rel);
return true;
}

Cardinality
PostgresTable::GetTableCardinality(Oid relid) {
auto rel = RelationIdGetRelation(relid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably needs the DuckdbProcessLock.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me give another pass through code; I'm seeing this RelationIdGetRelation used on few other places (unprotected by lock) maybe it is worth checking if this function can be used in only one function and than we would pass pointer to its data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tishj can you look into latest commit it should centralize opening/closing relation for execution

Copy link
Collaborator

@JelteF JelteF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the missing process lock I think this can be merged.

Like @Tishj said I think we can remove more code. But I'm also fine with that happening in a follow up PR.

@mkaruza mkaruza force-pushed the revert-index-scans branch from 5ac446b to 03538ce Compare October 7, 2024 08:16
@mkaruza mkaruza requested review from Tishj and JelteF October 7, 2024 08:16
auto tupleDesc = RelationGetDescr(rel);

if (!tupleDesc) {
elog(WARNING, "Failed to get tuple descriptor for relation with OID %u", relid);
elog(WARNING, "Failed to get tuple descriptor for relation with OID %u", rel->rd_id);
RelationClose(rel);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should now be removed I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. I'm thinking if this check is even needed? If we have relation object opened before should we always have tuple desc information?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that sounds reasonable. There's no way for this to fail. It's a simple macro that reads a field:

#define RelationGetDescr(relation) ((relation)->rd_att)

Copy link
Collaborator

@JelteF JelteF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, but other than that this looks good now.

@JelteF JelteF added the bug Something isn't working label Oct 7, 2024
@JelteF
Copy link
Collaborator

JelteF commented Oct 7, 2024

Oh one more small note (I forgot it last time too when merging a PR without squashing). Can you update the commit messages to include the PR number at the end of the title in parenthesis, ie. (#247)

Reverting index scan feature as explained in #183.
By removing index scan we don't need anymore to do query planning.
Remove this from execution. Table cardinality is directly calculated by
calling callback functions.
Opening and closing relation is not thread safe. So it would be better
that we open and close relation from central point and pass pointer to
structure for reading.
@mkaruza mkaruza force-pushed the revert-index-scans branch from 03538ce to b319fa1 Compare October 7, 2024 08:41
@mkaruza mkaruza merged commit b319fa1 into main Oct 7, 2024
4 checks passed
@mkaruza mkaruza deleted the revert-index-scans branch October 7, 2024 08:51
JelteF added a commit that referenced this pull request Oct 7, 2024
Since #247 is merged PostgresContextState is not actually used anymore.
So this removes it completely. This will make a bunch of PRs easier to
implement, specifically #241 and #206.
JelteF added a commit that referenced this pull request Oct 7, 2024
Since #247 is merged PostgresContextState is not actually used anymore.
So this removes it completely. This will make a bunch of PRs easier to
implement, specifically #241 and #206.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revert index scan functionality
3 participants