Which way is correct? Use distance or buffer? I am not sure about this. Here is how I use distance: cursor.execute(""" SELECT COUNT(tw.user_id) FROM tweets tw, ca_census_tract ce WHERE ST_Distance(ST_Transform(tw.location,26986), ST_Transform(ce.geom,26986))>=160934 AND ce.name10='Alameda'; """) cursor.fetchall() and here is how I use buffer: cursor.execute(""" SELECT COUNT(tw.user_id) FROM tweets tw, ca_census_tract ce WHERE ST_within(ST_Transform(tw.location,26986), ST_Buffer(ST_Transform(ce.geom,26986), 160934))=false AND ce.name10='Alameda'; """) cursor.fetchall() The tw.location are points. Thank you very much! ------EDIT------ There was a small difference in the result and a huge difference in running time. The result from distance was 14818 and the result from buffer was 14899. I don't understand why there was a difference. And, the running time of buffer was much longer. By the way, the total number of the dataset was 100K.