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

Have PgSelectStep leverage unary steps #1974

Open
benjie opened this issue Feb 27, 2024 · 1 comment
Open

Have PgSelectStep leverage unary steps #1974

benjie opened this issue Feb 27, 2024 · 1 comment

Comments

@benjie
Copy link
Member

benjie commented Feb 27, 2024

Relates to #1973; PgSelectStep and related classes should be able to addUnaryDependency for first/etc and thus not need to do such complex SQL for first/last/cursor/etc. Should be able to use this to eliminate some eval calls also?

@benjie
Copy link
Member Author

benjie commented Mar 19, 2024

If the dependency is a unary then instead of:

select __organization_memberships_result__.*
from (select 0 as idx, $1::"int4" as "id0") as __organization_memberships_identifiers__,
lateral (
  select
    __organization_memberships__."organization_id"::text as "0",
    __organization_memberships__."id"::text as "1",
    __organization_memberships_identifiers__.idx as "2"
  from "app_public"."organization_memberships" as __organization_memberships__
  where (
    __organization_memberships__."user_id" = __organization_memberships_identifiers__."id0"
  )
  order by __organization_memberships__."id" asc
) as __organization_memberships_result__;

we can do

  select
    __organization_memberships__."organization_id"::text as "0",
    __organization_memberships__."id"::text as "1"
  from "app_public"."organization_memberships" as __organization_memberships__
  where (
    __organization_memberships__."user_id" = $1::"int4"
  )
  order by __organization_memberships__."id" asc;

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

No branches or pull requests

1 participant