Skip to content

Too Much Input Exception When SELECTing Many AVG Columns #3326

@superichmann

Description

@superichmann

Describe the bug

When SELECTing 6000 columns AVG on the same SELECT there is an error.
ServerSide:

023-05-12T09:12:00.131416Z E i.q.s.BytecodeAssembler Too much input to generate io.questdb.griffin.engine.groupby.GroupByFunctionsUpdater. Bytecode is too long
2023-05-12T09:12:00.131435Z C i.q.c.p.PGWireServer internal error [ex=
io.questdb.std.ex.BytecodeException: Error in bytecode
	at io.questdb.std.ex.BytecodeException.<clinit>(BytecodeException.java:28)
	at io.questdb.std.BytecodeAssembler.endMethodCode(BytecodeAssembler.java:199)
	at io.questdb.griffin.engine.groupby.GroupByFunctionsUpdaterFactory.generateUpdateNew(GroupByFunctionsUpdaterFactory.java:220)
	at io.questdb.griffin.engine.groupby.GroupByFunctionsUpdaterFactory.getInstance(GroupByFunctionsUpdaterFactory.java:110)
	at io.questdb.griffin.engine.groupby.GroupByNotKeyedRecordCursorFactory.<init>(GroupByNotKeyedRecordCursorFactory.java:64)
	at io.questdb.griffin.SqlCodeGenerator.generateSelectGroupBy(SqlCodeGenerator.java:3336)
	at io.questdb.griffin.SqlCodeGenerator.generateSelect(SqlCodeGenerator.java:2665)
	at io.questdb.griffin.SqlCodeGenerator.generateQuery0(SqlCodeGenerator.java:2272)
	at io.questdb.griffin.SqlCodeGenerator.generateQuery(SqlCodeGenerator.java:2259)
	at io.questdb.griffin.SqlCodeGenerator.generate(SqlCodeGenerator.java:186)
	at io.questdb.griffin.SqlCompiler.generate(SqlCompiler.java:2731)
	at io.questdb.griffin.SqlCompiler.compileUsingModel(SqlCompiler.java:1322)
	at io.questdb.griffin.SqlCompiler.compileInner(SqlCompiler.java:1271)
	at io.questdb.griffin.SqlCompiler.compile(SqlCompiler.java:268)
	at io.questdb.cutlass.pgwire.PGConnectionContext.compileQuery(PGConnectionContext.java:1192)
	at io.questdb.cutlass.pgwire.PGConnectionContext.parseQueryText(PGConnectionContext.java:1699)
	at io.questdb.cutlass.pgwire.PGConnectionContext.processParse(PGConnectionContext.java:2358)
	at io.questdb.cutlass.pgwire.PGConnectionContext.parse(PGConnectionContext.java:1631)
	at io.questdb.cutlass.pgwire.PGConnectionContext.handleClientOperation(PGConnectionContext.java:418)
	at io.questdb.cutlass.pgwire.PGJobContext.handleClientOperation(PGJobContext.java:89)
	at io.questdb.cutlass.pgwire.PGWireServer$1.lambda$$0(PGWireServer.java:91)
	at io.questdb.network.AbstractIODispatcher.processIOQueue(AbstractIODispatcher.java:189)
	at io.questdb.cutlass.pgwire.PGWireServer$1.run(PGWireServer.java:128)
	at io.questdb.mp.Worker.run(Worker.java:118)
]

ClientSide (.NET):

    Npgsql.NpgsqlException: Exception while reading from stream ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.

  Stack Trace: 
    NpgsqlReadBuffer.<Ensure>g__EnsureLong|42_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
    --- End of inner exception stack trace ---
    NpgsqlReadBuffer.<Ensure>g__EnsureLong|42_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
    NpgsqlConnector.<ReadMessage>g__ReadMessageLong|232_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
    NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
    NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
    NpgsqlDataReader.NextResult()
    NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
    NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
    NpgsqlCommand.ExecuteReader(CommandBehavior behavior)

To reproduce

Create a table with a lot of columns.
SELECT AVG of each of them:
SELECT AVG(col1), AVG(col2), .... , AVG(colX) from tbl

Expected Behavior

the results of the query should be returned.

Environment

- **QuestDB version**:711
- **OS**:windows
- **Browser**:chrome

Metadata

Metadata

Labels

EnhancementEnhance existing functionalitySQLIssues or changes relating to SQL execution

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions