<div dir="ltr">Hi Vilem,<br><div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-08 16:26 GMT+01:00 Vilem Ded <span dir="ltr"><<a href="mailto:Ded.V@seznam.cz" target="_blank">Ded.V@seznam.cz</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Thanks, <br>very nice indeed! I will definitely give that a try. <br>But this is really very dependent on data distribution. My dataset is clustered so it will be better, but probably not good enough:/<br>As I understood KNN in Postgis is implemented with priority queue?<br>If so, there must be condition of type while i < k {next} , where k is our K in KNN. I was hoping for some way how to alter this part of code - "just" change those few lines..<br></div></blockquote><div><br></div><div>Yes, kNN in PostgreSQL is based on pairing heap algorithm, that provides a priority queue of index nodes at some point. Consider that kNN is supported in GiST indexing more in general - i.e., it is not just a part of PostGIS.</div><div><br></div><div>Regards,</div><div>Giuseppe.<br></div></div><br></div></div></div>