0

When I'm querying in PostgreSQL where I have used same foreign table in both from clause and where clause I'm getting timeout error. Whereas if I remove where clause and add it as cte it executes in less than a second. Kindly advise if this foreign tables has limitations in querying.

S-Man
  • 22,521
  • 7
  • 40
  • 63
  • Show your table schema (including indexes) and queries. – Shawn Oct 04 '18 at 16:22
  • No limitations. Postgres is just materializing the remote data in the CTE, so the query is more efficient. – Gordon Linoff Oct 04 '18 at 16:26
  • My query looks like this " select col from foreigntable1 join foreigntable2 on condition where f1.col in (select col from foreigntable2 where col is null) " so basically foreigntable2 is queries twice – Kaja Hussain Oct 04 '18 at 16:28
  • To add the table has very less volume of data 200+ rows – Kaja Hussain Oct 04 '18 at 16:31
  • Please **[EDIT]** your question and add the `create table` statements for the tables in question (including all indexes), the query you are using and the execution plan generated using **`explain (analyze, buffers)`** (not just a simple "explain". [Formatted text](http://stackoverflow.com/help/formatting) please, [no screen shots](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) –  Oct 04 '18 at 17:49

0 Answers0