@@ -106,9 +106,12 @@ export async function searchLocationsBySimilarCategories(
106106) : Promise < SearchLocationResponse [ ] > {
107107 try {
108108 const db = useDrizzle ( )
109+ const embStart = performance . now ( )
109110 const queryEmbedding = await generateEmbeddingCached ( query )
111+ logger . info ( `[perf] generateEmbedding ${ ( performance . now ( ) - embStart ) . toFixed ( 0 ) } ms` )
110112 const { origin, maxDistanceMeters, categories : requiredCategories , fetchLimit, page, limit : pageLimit } = options
111113
114+ const vecStart = performance . now ( )
112115 const vectorMatches = await db . execute ( sql `
113116 SELECT ${ tables . categories . id } as id
114117 FROM ${ tables . categories }
@@ -119,6 +122,7 @@ export async function searchLocationsBySimilarCategories(
119122 ` )
120123
121124 let categoryIds = ( ( vectorMatches as any ) . rows || [ ] ) . map ( ( row : any ) => row . id as string )
125+ logger . info ( `[perf] vectorSearch found=${ categoryIds . length } ${ ( performance . now ( ) - vecStart ) . toFixed ( 0 ) } ms` )
122126
123127 if ( categoryIds . length === 0 )
124128 categoryIds = pickFallbackCategories ( query )
@@ -198,7 +202,10 @@ export async function searchLocationsByCategories(
198202 ? baseQuery . orderBy ( selectFields . distanceMeters )
199203 : baseQuery . orderBy ( sql `${ tables . locations . rating } DESC NULLS LAST` )
200204
201- return await queryBuilder . limit ( limit ) . offset ( offset ) as SearchLocationResponse [ ]
205+ const catStart = performance . now ( )
206+ const rows = await queryBuilder . limit ( limit ) . offset ( offset ) as SearchLocationResponse [ ]
207+ logger . info ( `[perf] searchLocationsByCategories count=${ rows . length } ${ ( performance . now ( ) - catStart ) . toFixed ( 0 ) } ms` )
208+ return rows
202209}
203210
204211// PostgreSQL's built-in FTS is faster than vector search for exact/prefix matches
@@ -273,5 +280,8 @@ export async function searchLocationsByText(
273280 ? baseQuery . orderBy ( selectFields . distanceMeters )
274281 : baseQuery
275282
276- return await queryBuilder . limit ( limit ) . offset ( offset ) as SearchLocationResponse [ ]
283+ const txtStart = performance . now ( )
284+ const rows = await queryBuilder . limit ( limit ) . offset ( offset ) as SearchLocationResponse [ ]
285+ logger . info ( `[perf] searchLocationsByText count=${ rows . length } ${ ( performance . now ( ) - txtStart ) . toFixed ( 0 ) } ms` )
286+ return rows
277287}
0 commit comments