Informix 12.10 Find Percentage Completion Of Currently Running Query - informix

How to check percentage of job completed for long query?
I found this query for SQL Server:
SELECT
percent_complete,
der.estimated_completion_time / 1000 "estimated_completion_time_in_seconds",
*
FROM
sys.dm_exec_sessions des
INNER JOIN
sys.dm_exec_requests der ON des.session_id = der.session_id
AND des.status = 'running'
Is there a similar one for Informix?
Can anybody help?

Related

How to filter by price range in sample cube of kylin

Sorry, I just start to lean kylin
When I execute the sql select * from kylin_sales where price > 2 in default sample cube of kylin, it failed with the message
ERROR while executing SQL "select * from kylin_sales where price > 2 LIMIT 50000": Can't find any realization. Please confirm with providers SQL digest: fact table DEFAULT.KYLIN_SALES,group by [],filter on[DEFAULT.KYLIN_SALES.PRICE],with aggregates[].
anybody knows the reason?
Thanks
Kylin is a MOLAP (multidimensional online analytical processing) engine. It divides columns into dimensions and measures, expects queries to filter by dimensions and return aggregated measures.
Your query select * from kylin_sales where price > 2 does not work, because price is not a dimension thus is not suitable for filtering. Also the query does not select any aggregated measures.
A simple MOLAP query is like select week_beg_dt, sum(price) from kylin_sales where meta_categ_name='Collectibles' group by week_beg_dt
Kylin also supports a special type of RAW measure, that allows filter such as price > 2, but that's not demonstrated by the sample cube.

Transform SQL JOIN SELECT to Esper EPL syntax

Let's consider a simple object with the same representation in a SQL database with properties(columns¨): Id, UserId,Ip.
I would like to prepare a query that would generate event in case that one user logs in from 2 IP adresses (or more) within 1 hour period.
My SQL looks like:
SELECT id,user_id,ip FROM w_log log
LEFT JOIN
(SELECT user_id, count(distinct ip) AS ip_count FROM w_log GROUP BY user_id) ips
ON log.user_id = ips.user_id
WHERE ips.ip_count > 1
Transformation to EPL:
SELECT * FROM LogEntry.win:time(1 hour) logs LEFT INNER join
(select UserId,count(distinct Ip) as IpCount FROM LogEntry.win:time(1 hour)) ips
ON logs.UserId = ips.UserId where ips.IpCount>1
Exception:
Additional information: Incorrect syntax near '(' at line 1 column 100,
please check the outer join within the from clause near reserved keyword 'select'
UPDATE:
I was successfuly able to create a schema, named window and insert data into it (or update it). I would like to increase the counter when a new LogEvent arrives in the .win:time(10 seconds) and decrease it when the event is leaving the 10 seconds window. Unfortunately the istream() doesn't seem to provide the true/false when the event is in remove stream.
create schema IpCountRec as (ip string, hitCount int)
create window IpCountWindow.win:time(10 seconds) as IpCountRec
on LogEvent.win:time(10 seconds) log
merge IpCountWindow ipc
where ipc.ip = log.ip
when matched and istream()
then update set hitCount = hitCount + 1
when matched and not istream()
then update set hitCount = hitCount - 1
when not matched
then insert select ip, 1 as hitCount
Is there something I missed?
In EPL I don't think it is possible to put a query into the from-part. You can change using "insert into". An EPL alternative is also a named window or table.

esper how to find ID that exists in streamA but NOT EXITS in streamB

The problem is pretty simple: extract only the not exists records from 2 different streams using Esper engine.
ID exists in streamA but NOT EXITS in streamB.
In SQL it would look like this:
SELECT *
FROM tableA
WHERE NOT EXISTS (SELECT *
FROM tableB
WHERE tableA.Id = tableB.Id)
I've tried it Esper style but it doesn't work:
SELECT *
FROM streamA.win:ext_timed(timestamp, 5 seconds) as stream_A
WHERE NOT EXSITS
(SELECT stream_B.Id
FROM streamB.win:ext_timed(timestamp, 5 seconds) as stream_B
WHERE stream_A.Id = stream_B.Id)
Sadly if stream_A.Id inserted before stream_B.id than it will answer the query conditions and the query won't work.
Any suggestions on how to identify "ID exists in streamA but NOT EXITS in streamB" using Esper?
One simple way is to time-order the stream, so that A and B are timestamp ordered before sending events in.
Or you could delay A such as this query:
select * from pattern [every a=streamA -> timer:interval(1 sec)] as delayed_a
where not exists (... where delayed_a.a.id = b.id)
There is no need for an externally timed window for streamA. For externally timed behavior in general use external timer events.

TSQL Max Function not working right

Using TSQL -
Trying to get most recent MAX(HAR_ASSESSMENT.SESSION_DATE) but my query is returning the oldest assessment date instead of the most recent. I think it has something to do with the SERVICE_DELIVERIES join and parameter...any suggestions would be appreciated.
**SELECT
HAR_ASSESSMENTS.NEXT_SESSION_DATE
,HAR_CONSUMERS.CLIENT_ID
,HAR_CONSUMERS.FULL_NAME
,MAX (HAR_SERVICE_DELIVERIES.SERVICE_PERIOD_START) AS Max_SERVICE_PERIOD_START
,HAR_SERVICE_DELIVERIES.SERVICE
,HAR_ASSESSMENTS.ASSESSFORM_NAME
,MAX(HAR_ASSESSMENTS.SESSION_DATE) AS Max_SESSION_DATE
,HAR_SERVICE_DELIVERIES.AGENCY
,HAR_SERVICE_DELIVERIES.PROVIDER
,HAR_SERVICE_DELIVERIES.FUND_IDENTIFIER
FROM
HAR_CONSUMERS
INNER JOIN HAR_ASSESSMENTS
ON HAR_CONSUMERS.CONSUMER_UUID = HAR_ASSESSMENTS.CONSUMER_UUID
INNER JOIN HAR_SERVICE_DELIVERIES
ON HAR_CONSUMERS.CONSUMER_UUID = HAR_SERVICE_DELIVERIES.CONSUMER_UUID
WHERE
HAR_SERVICE_DELIVERIES.SERVICE_PERIOD_START >= #SERVICE_PERIOD_START
AND HAR_SERVICE_DELIVERIES.SERVICE_PERIOD_START <= #SERVICE_PERIOD_START2
AND HAR_SERVICE_DELIVERIES.SERVICE IN (#SERVICE)
AND HAR_ASSESSMENTS.ASSESSFORM_NAME IN (#ASSESSFORM_NAME)
AND HAR_ASSESSMENTS.AGENCY IN (#AGENCY)
GROUP BY
HAR_ASSESSMENTS.NEXT_SESSION_DATE
,HAR_CONSUMERS.CLIENT_ID
,HAR_CONSUMERS.FULL_NAME
,HAR_SERVICE_DELIVERIES.SERVICE
,HAR_ASSESSMENTS.ASSESSFORM_NAME
,HAR_SERVICE_DELIVERIES.AGENCY
,HAR_SERVICE_DELIVERIES.PROVIDER
,HAR_SERVICE_DELIVERIES.FUND_IDENTIFIER**

Linq to Sql and T-SQL Performance Discrepancy

I have an MVC web site the presents a paged list of data records from a SQL Server database. The UI allows the user to filter the returned data on a number of different criteria, e.g. email address. Here is a snippet of code:
Stopwatch stopwatch = new Stopwatch();
var temp = SubscriberDB
.GetSubscribers(model.Filter, model.PagingInfo);
// Inspect SQL expression here
stopwatch.Start();
model.Subscribers = temp.ToList();
stopwatch.Stop(); // 9 seconds plus compared to < 1 second in Query Analyzer
When this code is run, the StopWatch shows an execution time of around 9 seconds. If I capture the generated SQL expression (just before it is evaluated with the .ToList() method) and cut'n'paste that as a query into SQL Server Management Studio, the execution times drops to less than 1 second. For reference here is the generated SQL expression:
SELECT [t2].[SubscriberId], [t2].[Email], [t3].[Reference] AS [DataSet], [t4].[Reference] AS [DataSource], [t2].[Created]
FROM (
SELECT [t1].[SubscriberId], [t1].[SubscriberDataSetId], [t1].[SubscriberDataSourceId], [t1].[Email], [t1].[Created], [t1].[ROW_NUMBER]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Email], [t0].[SubscriberDataSetId]) AS [ROW_NUMBER], [t0].[SubscriberId], [t0].[SubscriberDataSetId], [t0].[SubscriberDataSourceId], [t0].[Email], [t0].[Created]
FROM [dbo].[inbox_Subscriber] AS [t0]
WHERE [t0].[Email] LIKE '%_EMAIL_ADDRESS_%'
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN 0 + 1 AND 0 + 20
) AS [t2]
INNER JOIN [dbo].[inbox_SubscriberDataSet] AS [t3] ON [t3].[SubscriberDataSetId] = [t2].[SubscriberDataSetId]
INNER JOIN [dbo].[inbox_SubscriberDataSource] AS [t4] ON [t4].[SubscriberDataSourceId] = [t2].[SubscriberDataSourceId]
ORDER BY [t2].[ROW_NUMBER]
If I remove the email filter clause, then the controller's StopWatch returns a similar response time to the SQL Management Studio query, less than 1 second - so I am assuming that the basic interface to SQL plumbing is working correctly and that the problem lies with the evaluation of the Linq expression. I should also mention that this is quite a large database with upwards of 1M rows in the subscriber table.
Can anyone throw any light on why there should be such a high (x10) performance differential and what, if anything can be done to address this?
Well not sure about that. 1M rows with a full like can take quiet time. Is Email indexed? Can you run the query with Email% instead of %Email% and see what happen?

Resources