我想要实现一个从DB检索500万条记录的代码。但是当我检索到它时,连接会打开很长时间,这会导致应用程序被长期卡住。也会导致内存不足的问题。
我使用PreparedStatementCreator设置了获取大小,这有助于快速检索数据。但在这一特定时期,当应用程序陷入困境时,其他用户无法访问该应用程序。
因此,我试图实现批选择,但Sybase ASE 16.3不支持偏移,限制,启动等。
我正在使用spring的using模板。
你能帮我解决这个问题吗?
你好,Ashish M
发布于 2022-02-07 03:13:20
Sybase建议使用temp表来完成这些分页工作--
eg.
create table #result (rid bigint identity, col1 int, col2 varchar...)
insert #result(col1,col2...) select ... from yourtable1, yourtable2 ... where ...
select * from #result where rid between 1 and 1000 -- page1
select * from #result where rid between 1001 and 2000 -- page2
...发布于 2022-02-05 01:56:01
您是否尝试过设置各种隔离级别,如下面的示例所示?
import java.sql.*;
Connection conn;
DatabaseMetaData dbmd;
<open connection>
dbmd = conn.getMetaData();
if (dbmd.supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED))
{
conn.setTransactionIsolation(TRANSACTION_READ_UNCOMMITTED);
}https://stackoverflow.com/questions/70974126
复制相似问题