Feed and search query perf tuning ()

Switch unnecessary unions to union all in pds queries
This commit is contained in:
devin ivy 2023-03-04 15:26:56 -05:00 committed by GitHub
parent 50c892c835
commit f57063bebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions
packages/pds/src
app-view/api/app/bsky/feed
services/util

@ -42,7 +42,7 @@ export default function (server: Server, ctx: AppContext) {
const keyset = new FeedKeyset(ref('cursor'), ref('postCid'))
let feedItemsQb = db
.selectFrom(postsQb.union(repostsQb).as('feed_items'))
.selectFrom(postsQb.unionAll(repostsQb).as('feed_items'))
.selectAll()
feedItemsQb = paginate(feedItemsQb, {
limit,

@ -55,7 +55,7 @@ export default function (server: Server, ctx: AppContext) {
const keyset = new FeedKeyset(ref('cursor'), ref('postCid'))
let feedItemsQb = db
.selectFrom(postsQb.union(repostsQb).as('feed_items'))
.selectFrom(postsQb.unionAll(repostsQb).as('feed_items'))
.selectAll()
feedItemsQb = paginate(feedItemsQb, {
limit,

@ -65,8 +65,8 @@ export const getUserSearchQueryPg = (
const resultsQb = db.db
.selectFrom(
emptyQb
.union(sql`${accountsQb}`) // The sql`` is adding parens
.union(sql`${profilesQb}`)
.unionAll(sql`${accountsQb}`) // The sql`` is adding parens
.unionAll(sql`${profilesQb}`)
.as('accounts_and_profiles'),
)
.selectAll()