@@ -11,9 +11,9 @@ import {
1111} from "../statement-index.js" ;
1212
1313const dialect : SqlQuerySiteDialect = {
14- classifyRelationAlias : ( rawAlias ) => ( {
14+ classifyIdentifierToken : ( rawIdentifier ) => ( {
1515 status : "identifier" ,
16- value : rawAlias ,
16+ value : rawIdentifier ,
1717 } ) ,
1818 decodeRelationPath : ( rawPath , cursorOffset ) => ( {
1919 finalSegment : { from : 0 , to : rawPath . length } ,
@@ -29,10 +29,20 @@ const dialect: SqlQuerySiteDialect = {
2929 maximumPathDepth : 16 ,
3030 supportsNaturalJoin : true ,
3131} ;
32- const tenKilobyteQuery = `SELECT ${ Array . from (
33- { length : 1_100 } ,
34- ( _ , index ) => `value_${ index } ` ,
35- ) . join ( ", " ) } FROM schema_prefix`;
32+ const TEN_KIBIBYTES = 10 * 1_024 ;
33+ const queryPrefix = "SELECT " ;
34+ const querySuffix = " FROM schema_prefix" ;
35+ const projectedListLength =
36+ TEN_KIBIBYTES - queryPrefix . length - querySuffix . length ;
37+ const projectedList = `${ "x," . repeat (
38+ Math . floor ( ( projectedListLength - 1 ) / 2 ) ,
39+ ) } x`;
40+ const tenKilobyteQuery = `${ queryPrefix } ${ projectedList } ${ " " . repeat (
41+ projectedListLength - projectedList . length ,
42+ ) } ${ querySuffix } `;
43+ if ( tenKilobyteQuery . length !== TEN_KIBIBYTES ) {
44+ throw new Error ( "Query benchmark fixture must be exactly 10 KiB" ) ;
45+ }
3646const source = createIdentitySqlSource ( tenKilobyteQuery ) ;
3747const index = buildSqlStatementIndex (
3848 source . analysisText ,
@@ -55,6 +65,21 @@ const aliasHeavySlot = findSqlStatementSlot(
5565 aliasHeavyPosition ,
5666 "left" ,
5767) ;
68+ const usingHeavyQuery = `SELECT * FROM first_table JOIN second_table USING(${ Array . from (
69+ { length : 1_000 } ,
70+ ( _ , columnIndex ) => `column_${ columnIndex } ` ,
71+ ) . join ( ", " ) } ) JOIN target`;
72+ const usingHeavySource = createIdentitySqlSource ( usingHeavyQuery ) ;
73+ const usingHeavyIndex = buildSqlStatementIndex (
74+ usingHeavySource . analysisText ,
75+ dialect . lexicalProfile ,
76+ ) ;
77+ const usingHeavyPosition = usingHeavyQuery . length ;
78+ const usingHeavySlot = findSqlStatementSlot (
79+ usingHeavyIndex ,
80+ usingHeavyPosition ,
81+ "left" ,
82+ ) ;
5883
5984describe ( "query-site recognizer" , ( ) => {
6085 bench ( "10 KiB active statement" , ( ) => {
@@ -69,4 +94,13 @@ describe("query-site recognizer", () => {
6994 dialect ,
7095 ) ;
7196 } ) ;
97+
98+ bench ( "1,000 authenticated USING columns" , ( ) => {
99+ recognizeSqlRelationQuerySite (
100+ usingHeavySource ,
101+ usingHeavySlot ,
102+ usingHeavyPosition ,
103+ dialect ,
104+ ) ;
105+ } ) ;
72106} ) ;
0 commit comments