Sybase ASE : Pagination



我想实现一个从DB中检索500万条记录的代码。但当我检索它时,连接是长时间打开的,这会导致应用程序被卡住很长时间。也会导致内存不足问题。

我已经使用PreparedStatementCreator来设置获取大小,这有助于快速检索数据。但在特定的时间段内,由于应用程序被卡住,其他访问该应用程序的用户无法使用该应用程序。

所以我试图实现批量选择,但Sybase ASE 16.3不支持Offset、Limit、Start-At等。

我使用的是spring的jdbctemplate。

你能帮我解决这个问题吗。

谨致问候,Ashish M

Sybase建议使用临时表来完成这些分页工作--

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
...

您是否尝试过设置各种隔离级别,如下面的示例中所示?

import java.sql.*;
Connection conn;
DatabaseMetaData dbmd;
<open connection>
dbmd = conn.getMetaData();
if (dbmd.supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED))
{ 
conn.setTransactionIsolation(TRANSACTION_READ_UNCOMMITTED); 
}

最新更新