[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Steven Hawkins (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Steven Hawkins resolved TEIID-5434.
-----------------------------------
Fix Version/s: 11.0.2
11.1
10.3.4
Resolution: Done
The placement of the select node is due fairly specific circumstances - in this case a union where a branch has a window function. In most instances the select node would be pushed under the source node. Addressed by updating the output columns of any intervening nodes.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Fix For: 11.0.2, 11.1, 10.3.4
>
> Attachments: count_plan.txt, count_plan_debug_log.txt, count_plan_text.txt, select_plan.txt, select_plan_debug_log.txt, select_plan_text.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Steven Hawkins (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Steven Hawkins commented on TEIID-5434:
---------------------------------------
The issue is with the sort optimization that is pulling up the distinct operation on the union to the join node. The intervening select node is having it's output columns left as the reduced set, so that when the distinct is processed it's over just the join predicate column. That is why you are seeing a smaller row count with the count query. I'll have a fix for this today.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, count_plan_debug_log.txt, count_plan_text.txt, select_plan.txt, select_plan_debug_log.txt, select_plan_text.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Steven Hawkins (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Steven Hawkins commented on TEIID-5434:
---------------------------------------
The join nodes are planned differently:
JoinNode(3) [Dependent] [ENHANCED SORT JOIN [SEMI] (SORT_DISTINCT/SORT)] [INNER JOIN] criteria=[convert(PatientID, long)=epa.PatientID] output=[]
JoinNode(1) [Dependent] [MERGE JOIN (SORT_DISTINCT/ALREADY_SORTED)] [INNER JOIN] criteria=[convert(PatientID, long)=epa.PatientID] output=[pa.ICUSessionID, DateTime, "Value"]
I'll see if that points to what could be the issue.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, count_plan_debug_log.txt, count_plan_text.txt, select_plan.txt, select_plan_debug_log.txt, select_plan_text.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Bram Gadeyne (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Bram Gadeyne commented on TEIID-5434:
-------------------------------------
I think you mean the result of the "PLAN_TEXT" column? I've added these aswell as the new debug log files. I can't seem to remove the old debug log files from this thread.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, count_plan_debug_log.txt, count_plan_text.txt, select_plan.txt, select_plan_debug_log.txt, select_plan_text.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Bram Gadeyne (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Bram Gadeyne updated TEIID-5434:
--------------------------------
Attachment: count_plan_debug_log.txt
count_plan_text.txt
select_plan_debug_log.txt
select_plan_text.txt
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, count_plan_debug_log.txt, count_plan_text.txt, select_plan.txt, select_plan_debug_log.txt, select_plan_text.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Bram Gadeyne (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Bram Gadeyne commented on TEIID-5434:
-------------------------------------
How can I obtain this query plan after execution? I now used "SET SHOWPLAN DEBUG" before executing the query and "SHOW PLAN" after executing the query.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, select_plan.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Steven Hawkins (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Steven Hawkins commented on TEIID-5434:
---------------------------------------
A quick glance at the plans would suggest that they only differ in projected symbols and the additional grouping operation for the count plan. Can you provide the query plan after execution showing the processing node row counts?
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, select_plan.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Steven Hawkins (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Work on TEIID-5434 started by Steven Hawkins.
---------------------------------------------
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, select_plan.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Bram Gadeyne (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Bram Gadeyne commented on TEIID-5434:
-------------------------------------
I'm fairly confident that in this case the output of count(*) is inaccurate.
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, select_plan.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months
[JBoss JIRA] (TEIID-5434) count(*) returns different nr of rows compared to normal select
by Bram Gadeyne (JIRA)
[ https://issues.jboss.org/browse/TEIID-5434?page=com.atlassian.jira.plugin... ]
Bram Gadeyne updated TEIID-5434:
--------------------------------
Attachment: count_plan.txt
select_plan.txt
> count(*) returns different nr of rows compared to normal select
> ---------------------------------------------------------------
>
> Key: TEIID-5434
> URL: https://issues.jboss.org/browse/TEIID-5434
> Project: Teiid
> Issue Type: Bug
> Affects Versions: 10.3.3
> Reporter: Bram Gadeyne
> Assignee: Steven Hawkins
> Priority: Critical
> Attachments: count_plan.txt, select_plan.txt
>
>
> Normal select return 162175 rows:
> {code:sql}
> select pa.ICUSessionID,11074, obr.DateTime, obr.varvalue, true, 15001866
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> count query return a count of 11573
> {code:sql}
> select count(*)
> from tv_retrieve_observrec obr
> join kd_matric.ExtrPatICUAdmissions epa on epa.PatientID = obr.admissionid
> join kd_matric.PatICUAdmissions pa on pa.ICUSessionID = epa.ICUSessionID and pa.BatchID < 1152
> where obr.VariableID = 15001866;
> {code}
> This was detected on a snapshot release of 10.3.3
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 4 months