You can translate the question and the replies:

Query seems to be ignoring sql table clustered index

I have a base view pointing to a single MSSQL table. The table has a clustered index. The table has approximately 6 million rows in it. When I run the query from DBeaver using a simple where clause I get the same expected result as when I run the query from MSSQL. The result is returned instantly. ``` select * from MyTable AS k01 where k01.p_logicaldate = '03 Jan 2017 12:00:00 AM' and k01.p_todate = '03 Jan 2017 12:00:00 AM' and k01.brk_cde = 9 and k01.acc_cde = 4 ``` However when I extend the query like below the query being run from DBeaver eventually times out. The same query in MSSQL returns results instantly. It seems to me that the query being submiitted to Denodo from DBeaver is incorrect and is completely excluding part of the where clause.. ``` select * from MyTable AS k01 where k01.p_logicaldate = '03 Jan 2017 12:00:00 AM' and k01.p_todate = '03 Jan 2017 12:00:00 AM' and ((k01.brk_cde = 9 and k01.acc_cde = 4) OR (k01.brk_cde = 48 and k01.acc_cde = 2004)) ``` I ran SQL profiler and got the following result ``` declare @p1 int set @p1=0 exec sp_prepexec @p1 output,N'@P0 datetime2,@P1 datetime2',N'SELECT t0.BRK_CDE, t0.ACC_CDE FROM BDAVault.dbo.K01 t0 WHERE t0.K01SysEFD <= coalesce(@P0, t0.K01SysEFD, null) AND (t0.K01SysETD IS NULL OR t0.K01SysETD >= coalesce(@P1, t0.K01SysETD, null)) ','2017-01-03 00:00:00','2017-01-03 00:00:00' select @p1 ``` As can be seen the query being submitted is leaving out the filter part of the where clause ``` and ((k01.brk_cde = 9 and k01.acc_cde = 4) OR (k01.brk_cde = 48 and k01.acc_cde = 2004)) ``` The clustered index is based on the dates, brk_cde and acc_cde Thank you in advance.
user
21-02-2017 02:01:27 -0500
code

1 Answer

Hi, I tried to do what you explained and I was able to do it successfully. You can check if there is any line space between the 'where' conditions before running the query because when you have line space, the query after the line space will not be executed. Example, select * from MyTable AS k01 where k01.p_logicaldate = '03 Jan 2017 12:00:00 AM' and k01.p_todate = '03 Jan 2017 12:00:00 AM' and ((k01.brk_cde = 9 and k01.acc_cde = 4) OR (k01.brk_cde = 48 and k01.acc_cde = 2004)) If your queries contains blank lines, you could try using other Data Visualizer tools like DBVisualizer. Hope this helps!!
Denodo Team
22-02-2017 23:36:20 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here