<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Hey,<br></div><div class="gmail_default" style="font-family:monospace,monospace">I fiind it difficult to understand exactly your problem.<br></div><div class="gmail_default" style="font-family:monospace,monospace">If you have a set of point A in python , of about 100 points,<br></div><div class="gmail_default" style="font-family:monospace,monospace">and a set of point B, in postgres, of a few million points,<br></div><div class="gmail_default" style="font-family:monospace,monospace">and that you want to find which point of A are already in B,<br></div><div class="gmail_default" style="font-family:monospace,monospace">you wouldn't need to import your python points into a temp postgres table and index it.<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">If your points are simple (for instance, only 2D, each dim an int),<br></div><div class="gmail_default" style="font-family:monospace,monospace">you may skip postgis altogether.<br></div><div class="gmail_default" style="font-family:monospace,monospace">Checking 100 points against few million should be <10ms with indexes.<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">You can check ta<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-13 20:46 GMT+02:00 Leknín Řepánek <span dir="ltr"><<a href="mailto:godzilalalala@gmail.com" target="_blank">godzilalalala@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Python Array -> geometry(POINT, [SRID])[] -> unnest, you can use unnest<br>
in CTE<br>
something like<br>
<br>
WITH cte AS (<br>
        SELECT unnest(array['POINT(1 1)'::geometry ......]) pnt<br>
)<br>
SELECT * FROM t JOIN cte ON ST_....<br>
<br>
<br>
Milions of points aren`t big data, if it is slow, maybe you should check<br>
your indexes.<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Jun 13, 2016 at 08:08:34AM -0700, Michal Seidl wrote:<br>
> Hello,<br>
> I have probably simple question but I am stuck. I have table with about 1E6<br>
> points in table. I have about hundreds of points in Python array. How to<br>
> pass these points into Postgis SQL query to check against table (if the same<br>
> point exist) with millions points?<br>
><br>
> I started with Python loop to check every point individually but it is slow.<br>
> I have found lots of receipts how to fight with large data but they have to<br>
> be already in database.<br>
><br>
> Which way is good for this situation?<br>
> - create temporary table and firstly insert points into DB<br>
> - try to manage Python not to close connection and send SQL query with each<br>
> point fast<br>
> - try to push all points in one query? How?<br>
> - write stored procedure that will accept array of data?<br>
> - anything else?<br>
><br>
> May be it is more general SQL questions, but i am working with points.<br>
><br>
> Thanks for advice Michal<br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://postgis.17.x6.nabble.com/Performance-external-loop-WHERE-IN-values-stored-procedure-or-else-to-pass-data-to-SQL-query-tp5010138.html" rel="noreferrer" target="_blank">http://postgis.17.x6.nabble.com/Performance-external-loop-WHERE-IN-values-stored-procedure-or-else-to-pass-data-to-SQL-query-tp5010138.html</a><br>
> Sent from the PostGIS - User mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a></div></div></blockquote></div><br></div>