0

Is there any performance gain by the interpreter of the query is I specify the table on a join and make the cast explicit?

Instead of

...
join table_join on field1_from = field1_join and field2_join = '2'
...

using

...
join table_join on table_from.field1_from = table_join.field1_join and table_join.field2_join::text = '2'::text
...

It seems that this should make the job of the parser a little easier

1
  • 1
    What data type is field2_join? If that is a number you shouldn't compare it to a string. But in general, to find out if two queries are in the same way, check the execution plan generated using explain (analyze, verbose, buffers) to Sep 3 '18 at 18:33
2

It is a good practice to use aliases to qualify tables etc

Select a.c1, b.c2
From table1 as a
 ....

However, that has very little to do with performance. Identifying each table etc is only a fraction of what the optimizer does and I would be surprised if it even is noticeable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.