why impala explain sql not execute ? it execute very long time - impala

I want to execute explain sql statement with impala,
but is is executed very long time and not get result about 2 hours
,sql statement have a lot of where clause like this:
explain select * from a where (a is not null or b is not null or c in ("","","") ...);
i want to konw why explain sql is so slowly
or what i can do to ?
explain sql is here

Related

SQL - SELECT statement precedence (Query vs. Sub-Query)

Hi everyone I am wondering if someone can help me understand why the Sub-Query's SELECT statement ended up producing the column name 'Code' vs. the initial SELECT statement call 'local_name' in the below screenshot. Thank you

Get the list of result from first sql query and execute second query on the result of list of first query

So, I am working with redshift and SQL for the first time. I have run into this problem due to my limted knowledge of SQL.
I have this first query which return me tables with the columnA. (TableX, TableY... etc)
SELECT tablename
FROM PG_TABLE_DEF
WHERE ("column" = 'columnA');
Also I have this second query which returns me all the rows from the table containig certain value of columnA.
SELECT *
FROM TableX
WHERE columnA='123934'
What I want to achieve is take the result from the first query which is list of tables, and for each table run the second query i.e. get the rows with value of columnA=123934 for each table returned from first query.
What you want to achieve is done using dynamic SQL. Dynamic queries let you run a query from a string.
I am not an Redshit user but to generate the SQL string you need to run you could use the following query:
SELECT 'SELECT * FROM '||tablename ||' WHERE ColumnA= ''123934''; '
FROM PG_TABLE_DEF
WHERE ("column" = 'columnA');
You can try running it manually.

select not working after putting where condition in nicknames?

I have a remote mainframe db2 database for which I have created nicknames in my db2 server .
Problem is as below -
When I run query
SELECT * FROM LNICKNAME.TABLE - It runs and I can get all columns.
but if I run below query it never gives me any output and keeps running .
SELECT * FROM LNICKNAME.TABLE a where a.columnB = 'ADH00040';
So technically it does not work if I add any where condition .
It doesn't seem like there is an error with your SELECT statement. So I am assuming that one of two things are happening:
Senario 1:
The file is really big and there isn't an index on columnB. If this is the case it would take long as the DB would have to read through each record and check if columnB = 'ADH00040'. To see how many records are in the table just run a count on the table
SELECT COUNT(*) FROM LNICKNAME.BMS_TABLE
Senario 2:
Something or someone is disconnecting your connection before your query is complete. I know you can limit the amount of CPU time a iSeries job is allowed before it gets ended forceably (CHGJOB CPUTIME(60000)). Is there no form of a job log that you could share with us?
Are you sure your value is into your table?
try a like :
SELECT * FROM LNICKNAME.TABLE a where a.columnB like '%ADH00040%';

SQL Where logic parameterized where

I'm attempting to create a parameterized where statement using COALESCE in SQL 2008, and I have the example of:
Select *
From Receipts
Where Receipts.FunctionCode = COALESCE(#FunCode, Receipts.FunctionCode)
in hope that if i pass in NULL in #FunCode, it will pull all 7050 records. However its only pulling back 236 records, and same as if the where was this:
Where Receipts.FunctionCode = Receipts.FunctionCode
Can someone explain what logic is wrong for me? To me, this where statement should always pull 100% back the database
That is due to the NULL values present in the FunctionCode column try this instead. This will use index created on FunctionCode if any
Select *
From Receipts
Where Receipts.FunctionCode = #FunCode or #FunCode IS NULL

Huge condition with connect by in Oracle

I have some optimization problem with Oracle 11g database. I got query with structure as below:
select
(....)
from
(select ...)
where
(...)
CONNECT BY
PRIOR J.JDN_ID_POD = J.JDN_ID_NAD and (HUGE_CONDITION)
START WITH
J.JDN_ID_NAD = 1 and (HUGE_CONDITION)
and because of HUGE_CONDITION is really huge (~3500 characters) and is in two places, the query is very slow; is there any way to do it in another way?