fix(oracle): reduce view query page round trips
This commit is contained in:
2 files changed
+33
-1
No files matched your search
@@ -30,7 +30,11 @@ import (
|
||||
const protocolVersion = 1
|
||||
const multiSessionProtocolVersion = 2
|
||||
const defaultMaxRows = 1000
|
||||
const oracleDefaultPrefetchRows = "100"
|
||||
|
||||
// A normal data-grid page contains 100 rows. Prefetching a little more than
|
||||
// one page reduces round trips while reading subsequent pages without
|
||||
// buffering the much larger export limit.
|
||||
const oracleDefaultPrefetchRows = "256"
|
||||
const oracleCharsetZHS32GB18030 = 854
|
||||
const legacyAgentSessionID = "__legacy__"
|
||||
const maxAgentSessions = 256
|
||||
@@ -3974,6 +3978,13 @@ func readQuerySessionPage(session *querySession, pageSize int) (result queryPage
|
||||
result.Truncated = true
|
||||
return result, nil
|
||||
}
|
||||
// A full page is enough evidence that another page may exist. Do not read
|
||||
// one extra row just to decide has_more: with a prefetch boundary this
|
||||
// forces another Oracle round trip before the first page can be displayed.
|
||||
if len(result.Rows) >= pageSize {
|
||||
result.HasMore = true
|
||||
return result, nil
|
||||
}
|
||||
if session.rows.Next() {
|
||||
row, err := scanRow(session.rows, len(session.columns), session.columnTypes)
|
||||
if err != nil {
|
||||
|
||||
@@ -1183,6 +1183,27 @@ func TestBuildDSNUsesStableDefaultPrefetchRows(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadQuerySessionPageDoesNotLookAheadAfterFullPage(t *testing.T) {
|
||||
db, _ := openOracleViewSourceTestDB(t, []oracleViewSourceQueryStep{{
|
||||
queryContains: "SELECT * FROM TEST_VIEW",
|
||||
args: []driver.Value{},
|
||||
columns: []string{"ID"},
|
||||
rows: [][]driver.Value{{int64(1)}, {int64(2)}},
|
||||
}})
|
||||
s := newServer()
|
||||
s.db = db
|
||||
result, err := s.executeQueryPage(queryOptions{SQL: "SELECT * FROM TEST_VIEW"}, 2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result.Rows) != 2 || !result.HasMore || result.SessionID == nil {
|
||||
t.Fatalf("full page should keep a lazy session without look-ahead: %+v", result)
|
||||
}
|
||||
if !s.closeQuerySession(*result.SessionID) {
|
||||
t.Fatal("expected the query session to close")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDSNPreservesConfiguredPrefetchRows(t *testing.T) {
|
||||
tests := []connectParams{
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user