Column is in more than one table?

2021-09-28 Thread John English
If I issue the following query: SELECT t_time,facility FROM system_log,(SELECT time FROM system_log ORDER BY facility) AS x WHERE system_log.time=x.time I get an error: "Column name 'FACILITY' is in more than one table in the FROM list." Why does it consider Facility to be a column in

Re: Using indexes

2021-09-28 Thread John English
On 27/09/2021 18:23, John English wrote: I'll try the temporary table approach as soon as I get a minute, and will let you know what happens. I'm finally getting somewhere. Having (a) moved the row counting out to a separate query, (b) renamed columns in the table to match what my code

Re: Using indexes

2021-09-28 Thread John English
A couple more data points, from testing different variants of the inner select: 1) SELECT time FROM system_log ORDER BY time DESC NULLS LAST FETCH NEXT 20 ROWS ONLY; 419ms, "Index Scan ResultSet for SYSTEM_LOG using index LOG_INDEX at read uncommitted isolation level using share row

Re: Column is in more than one table?

2021-09-28 Thread John English
On Tue, 28 Sep 2021, 17:59 Rick Hillegas, wrote: > On 9/28/21 4:51 AM, John English wrote: > > If I issue the following query: > > SELECT t_time,facility FROM system_log,(SELECT time FROM system_log ORDER > BY facility) AS x WHERE system_log.time=x.time > > I get an error: "Column name

Re: Column is in more than one table?

2021-09-28 Thread Rick Hillegas
On 9/28/21 4:51 AM, John English wrote: If I issue the following query: SELECT t_time,facility FROM system_log,(SELECT time FROM system_log ORDER BY facility) AS x WHERE system_log.time=x.time I get an error: "Column name 'FACILITY' is in more than one table in the FROM list." Why does it

Re: Using indexes

2021-09-28 Thread John English
On Tue, 28 Sep 2021, 17:52 Rick Hillegas, wrote: > Glad that you have made progress on this puzzle. One comment inline... > > On 9/28/21 4:10 AM, John English wrote: > > The WHERE clause seems to prevent the index from being used. > The index is not usable in this query because username is not

Re: Using indexes

2021-09-28 Thread Rick Hillegas
Glad that you have made progress on this puzzle. One comment inline... On 9/28/21 4:10 AM, John English wrote: A couple more data points, from testing different variants of the inner select: 1) SELECT time FROM system_log ORDER BY time DESC NULLS LAST FETCH NEXT 20 ROWS ONLY; 419ms,