[ScanMail-Spam] Slowness in testing any crossing straight lines in a layer
Paul Ramsey
pramsey at cleverelephant.ca
Thu Feb 5 07:00:48 PST 2026
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 <bo.guo at gisticinc.com> 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 <Julien.MONTICOLO at strasbourg.eu <mailto:Julien.MONTICOLO at strasbourg.eu>> 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:bo.guo at gisticinc.com <mailto:bo.guo at gisticinc.com>]
>> Envoyé : jeudi 5 février 2026 13:53
>> À : PostGIS Users Discussion <postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>>
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20260205/c8923280/attachment.htm>
More information about the postgis-users
mailing list