Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread David Rowley
On Tue, 7 Jul 2020 at 09:03, Simon Riggs wrote: > > On Mon, 6 Jul 2020 at 21:49, David Rowley wrote: >> >> On Tue, 7 Jul 2020 at 00:43, Simon Riggs wrote: >> > >> > On Mon, 6 Jul 2020 at 12:37, Robins Tharakan wrote: >> >> (SELECT 1 FROM pg_class) UNION (SELECT 1 FROM pg_class); >> >> vs. >> >>

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Simon Riggs
On Mon, 6 Jul 2020 at 21:49, David Rowley wrote: > On Tue, 7 Jul 2020 at 00:43, Simon Riggs wrote: > > > > On Mon, 6 Jul 2020 at 12:37, Robins Tharakan wrote: > > > >> > >> When an SQL needs to UNION constants on either side, it should be > possible to > >> implicitly apply a LIMIT 1 and get go

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread David Rowley
On Tue, 7 Jul 2020 at 00:43, Simon Riggs wrote: > > On Mon, 6 Jul 2020 at 12:37, Robins Tharakan wrote: > >> >> When an SQL needs to UNION constants on either side, it should be possible to >> implicitly apply a LIMIT 1 and get good speed up. Is this an incorrect >> understanding, >> or somethin

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Michael Lewis
On Mon, Jul 6, 2020 at 5:37 AM Robins Tharakan wrote: > This need came up while reviewing generated SQL, where the need was to > return true when > at least one of two lists had a row. > Generated SQL... yep. That will happen. Manual SQL may be more work, but often has significant reward. If yo

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Simon Riggs
On Mon, 6 Jul 2020 at 12:37, Robins Tharakan wrote: > When an SQL needs to UNION constants on either side, it should be possible > to > implicitly apply a LIMIT 1 and get good speed up. Is this an incorrect > understanding, > or something already discussed but rejected for some reason? > > This

Re: Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Francisco Olarte
Robins: On Mon, Jul 6, 2020 at 1:37 PM Robins Tharakan wrote: > When an SQL needs to UNION constants on either side, it should be possible to > implicitly apply a LIMIT 1 and get good speed up. Is this an incorrect > understanding, > or something already discussed but rejected for some reason?

Apply LIMIT when computation is logically irrelevant

2020-07-06 Thread Robins Tharakan
Hi, When an SQL needs to UNION constants on either side, it should be possible to implicitly apply a LIMIT 1 and get good speed up. Is this an incorrect understanding, or something already discussed but rejected for some reason? This need came up while reviewing generated SQL, where the need was