Depends on your data. If the && operator is not particularly selective in your case, you’re evaluating 100K * 100K = 10000000000 crossing tests. P
> On Feb 5, 2026, at 5:59 AM, Bo Guo <[email protected]> wrote: > > Hi Julien, > > That makes sense. I added a.id <http://a.id/> > b.id <http://b.id/>. It > still took 17 minutes, however. > > Bo > > On Thu, Feb 5, 2026 at 6:00 AM MONTICOLO Julien > <[email protected] <mailto:[email protected]>> > wrote: >> Hello, >> >> >> >> When doing a cross join (my_fishbones a, my_fishbones b), you multiply a by >> b, so 100K by 100K. >> >> If your table has 3 records : 1, 2, 3, the cross join outputs : 1|1, 1|2, >> 1|3, 2|1, 2|2, 2|3, 3|1, 3|2, 3|3. >> >> There are unnecessary crosses. >> >> >> >> Add a condition : a.id <http://a.id/> > b.id <http://b.id/> to traverse only >> the half of the matrix. >> >> >> >> Kind regards >> >> >> >> De : Bo Guo [mailto:[email protected] <mailto:[email protected]>] >> Envoyé : jeudi 5 février 2026 13:53 >> À : PostGIS Users Discussion <[email protected] >> <mailto:[email protected]>> >> Objet : [ScanMail-Spam] Slowness in testing any crossing straight lines in a >> layer >> >> >> >> Hi There! >> >> >> >> I have 100K straight lines in a layer - my_fishbone - with GIST indexed. >> However, the following SQL query did not finish within 20 minutes! Could >> you advise on any improvement ideas? >> >> >> >> SELECT a.*, b.id <http://b.id/> >> FROM my_fishbones a, my_fishbones b >> WHERE a.geom && b.geom >> AND ST_Crosses(a.geom, b.geom) >> >> >> >> Thanks in advance! >> >> >> >> Bo Guo >> >> >> >> Ce message est établi à usage exclusif de son destinataire. >> Toute utilisation ou diffusion, partielle ou totale, doit être préalablement >> autorisée. >> >> Tout message électronique est susceptible d'altération et son intégrité ne >> peut être assurée. >> L'expéditeur décline toute responsabilité au titre de ce message s'il a été >> modifié ou falsifié. >> >> Si vous n'êtes pas destinataire de ce message, merci de le détruire et >> d'avertir l'expéditeur. >> >> Ville et Eurométropole de Strasbourg
