我使用 PHP VIA ODBC 连接到 Aster DB。我正在运行一个需要很长时间才能运行的查询。我已添加限制以仅获取 1000 条记录。在显示这些记录时,它会打印准确的 1000 条记录,但是当我打印总行数时,它会显示一个非常大的数字(140393890971647)。
为什么它只打印 1000 时返回错误的行数。我需要知道确切的行数,因为我必须将数据分成块插入到 PostgreSQL 中。
这是我对 aster 的查询:
select new_ean as ean, com_email as email, ranking from (select new_ean, com_email, rank() over (partition by com_email order by new_ean) as ranking from (select distinct p1.ean as new_ean , c.com_email from bn.table1 p1 join bn.table2 pcm1 on p1.ean = pcm1.ean join bn.table2 pcm2 on pcm1.contributor_id = pcm2.contributor_id join bn.table1 p2 on pcm2.ean = p2.ean join bn.table3 coi on coi.ean = pcm2.ean and demand_dt > current_date-730 join bn.table4 c on coi.customer_sk = c.customer_sk where p1.ean in (long list of coma separated ean here) and p2.inc_category_code = p1.inc_category_code) sq1) sq2 where ranking <= 4 order by new_ean asc
limit 1000 OFFSET 1
这是我的php代码:
$rs = odbc_exec($aster, $sql);
echo "Tot Rows :".odbc_num_rows($rs). " <br> ";
while ($row = odbc_fetch_row($rs))
{
echo "<br>" . odbc_result($rs,1) . "===" . odbc_result($rs,2) . "===" .odbc_result($rs,3);
}