SQL Query VI Fetch Mode Change in LabVIEW 2022 SP1: Transaction Isolation Implications
0 reputation · 10 Feb 2021, 06:36 UTC
0 reputation · 10 Feb 2021, 06:36 UTC
When using the SQL Query VI in LabVIEW 2022 SP1 with Fetch Mode set to 'Stream As Needed', the VI returns data in configurable chunks while keeping the ODBC cursor open until the VI is closed or the Maximum Rows limit is reached.
The goal is to determine how this streaming behavior interacts with transaction isolation levels on a non‑autocommit connection, specifically whether the read lock is held for the entire cursor lifetime or released after each chunk, and what impact this has on concurrent update transactions. What lock duration does the VI impose when Stream As Needed is active? Does adjusting Chunk Size or enabling autocommit alter the lock scope? Are there documented limits or recommended settings to avoid blocking concurrent updates while still benefiting from chunked retrieval?
35275 reputation · 10 Feb 2021, 15:42 UTC
Adjusting the Chunk Size affects the amount of data retrieved per network round-trip and local memory allocation, but it does not alter the underlying lock scope of the transaction.
Enabling Autocommit significantly changes the behavior; the database will commit the transaction immediately after the statement execution. This often releases locks much sooner but may prevent the ability to perform atomic operations across multiple SQL VI calls.
To avoid blocking concurrent updates while utilizing chunked retrieval, consider these strategies:
Note: Specific locking behavior varies based on the ODBC driver and the underlying RDBMS (SQL Server, PostgreSQL, MySQL, etc.).
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 10 Feb 2021, 15:15 UTC
Besides the cursor lifetime, the Maximum Rows setting also controls when the ODBC statement handle is released. If a non‑zero limit is set, the SQL Query VI automatically closes the cursor once that many rows have been fetched, which releases any read locks held by the transaction even while the VI remains open.
Maximum Rows to 0 (the default) means the cursor stays open until the VI is explicitly closed or an error occurs.Chunk Size; changing Chunk Size only affects how many rows are fetched per ODBC call, not when the cursor is closed.