I am connected to Aster DB using PHP VIA ODBC. I am running a query which is taking a long time to run. I have added limit to get 1000 records only. While displaying those records, it prints exact 1000 records, but when I print total number of rows it displays a very large number (140393890971647).
Why is it returning wrong row nums while its printing 1000 only. I need to know exact number of rows as I have to break data in chunks to insert in PostgreSQL.
Here is my query for 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
Here is my php code:
$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);
}