查询行9,000,000到10,000,000

时间:2015-07-07 11:27:57

标签: sql postgresql

postgresql新手,我有一个10,000,000行的表,我一次查询数百万行

SELECT mmsi, report_timestamp, position_geom, ST_X(position_geom) AS Long,ST_Y(position_geom) AS Lat 
FROM reports4 
WHERE position_geom IS NOT NULL 
ORDER by report_timestamp ASC 
LIMIT 1000000 
OFFSET 8000000

当我尝试查询最后几百万行时,没有显示任何内容

SELECT mmsi, report_timestamp, position_geom, ST_X(position_geom) AS Long,ST_Y(position_geom) AS Lat 
FROM reports4 
WHERE position_geom IS NOT NULL 
ORDER by report_timestamp ASC 
LIMIT 1000000 
OFFSET 9000000

不确定如果我正确地进行查询,或者我忽略了某些事情。

1 个答案:

答案 0 :(得分:5)

该表可能包含10,000,000行,但这些行中有多少行WHERE position_geom IS NOT NULL

你得到了什么:

SELECT count(*)
FROM reports4
WHERE position_geom IS NOT NULL;