|
Archives of the TeradataForumMessage Posted: Wed, 12 Feb 2003 @ 23:50:18 GMT
I have created a Multitable Aggregate Join Index, but can't seem to get the SQL to use it. Below you will find all related information related to this task. I would greatly appreciate any suggestions. Create for Aggregate Join Index: CREATE JOIN INDEX JoinIndex1 ,NO FALLBACK AS SELECT COUNT(*)(FLOAT, NAMED CountStar ), DatabaseName.Table2.Column23 , DatabaseName.Table1.Column12, DatabaseName Table1.Column13, SUM(DatabaseName.Table1.Column15 )(FLOAT, NAMED Column15 ), SUM(DatabaseName.Table1.Column16 )(FLOAT, NAMED Column16 ), SUM(DatabaseName.Table1.Column17 )(FLOAT, NAMED Column17 ), SUM(DatabaseName.Table1.Column18 )(FLOAT, NAMED Column18 ) FROM (DatabaseName.Table1 Table1 INNER JOIN DatabaseName.Table2 Table2 ON DatabaseName.Table1.Column11 = DatabaseName.Table2.Column21 ) GROUP BY DatabaseName.Table2.Column23 ,DatabaseName.Table1.Column12 ,DatabaseName.Table1.Column13 PRIMARY INDEX ( Column23 ,Column12 ,Column13 ); Statistics for Aggregate join Index: Date Time Unique Values Column Names 03/02/12 14:19:47 1,551,653 Column23,Column12,Column13 Create DDL for DatabaseName.Table1: CREATE SET TABLE DatabaseName.Table1 ,NO FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL ( Column11 INTEGER NOT NULL, Column12 SMALLINT NOT NULL, Column13 DATE FORMAT 'YYYY-MM-DD' NOT NULL, Column14 CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT 'L', Column14 DECIMAL(9,2) NOT NULL DEFAULT 0.00 , Column16 DECIMAL(9,2) NOT NULL DEFAULT 0.00 , Column17 INTEGER NOT NULL DEFAULT 0 , Column18 DECIMAL(9,2) NOT NULL DEFAULT 0.00 ) PRIMARY INDEX ( Column11,Column12,Column13 ); Statistics for DatabaseName.Table1: Date Time Unique Values Column Names 03/02/12 15:05:50 528 Column11 03/02/12 15:06:00 994 Column12 03/02/12 15:06:05 111 Column13 03/02/12 15:06:10 1 Column14 03/02/12 15:06:14 21,411,105 Column11,Column12,Column13 Create DDL for DatabaseName.Table2: CREATE SET TABLE DatabaseName.Table2 ,NO FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL ( Column21 INTEGER NOT NULL, Column22 INTEGER NOT NULL, Column23 INTEGER NOT NULL, Column24 INTEGER NOT NULL, Column25 CHAR(40) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL DEFAULT ' ') UNIQUE PRIMARY INDEX ( Column21 ); Statistics for DatabaseName.Table2: Date Time Unique Values Column Names 03/02/12 10:40:00 834 Column21 03/02/12 10:40:12 63 Column22 03/02/12 10:40:14 22 Column23 03/02/12 10:40:16 4 Column24 SQL: select Table2.Column23, Table1.Column12, Table1.Column13, sum(Table1.Column15) As Column15 from DatabaseName.Table1 Table1 join DatabaseName.Table2 Table2 on Table2.Column21 = Table1.Column11 and Table2.Column23 = 23 and Table1.Column12 = 999 and Table1.Column13 = '2003-01-31' group by 1, 2, 3; Explain:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||