﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Teradata Forums / Data Warehousing  / Teradata   / Query select..where..in on a partitioned table: partitions are not used / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Teradata Forums</description><link>http://www.teradata.com/teradataforum/</link><webMaster>info@teradata.com</webMaster><lastBuildDate>Wed, 03 Dec 2008 20:11:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query select..where..in on a partitioned table: partitions are not used</title><link>http://www.teradata.com/teradataforum/Topic11131-1-1.aspx</link><description>If you want to check if data exists, then better use a EXISTS instead of SAMPLE 1, this should always be sub-second instead of 15 seconds:SELECT 'exists'WHERE exists (  SELECT * FROM toutput  WHERE field1_cd = 'code1'  AND mese_cd = 200803 )The same for the volatile table:SELECT 'exists'WHERE EXISTS (SELECT * FROM toutput, vt WHERE vt.mese_cd = toutput.mese_cd AND toutput.field1_cd = 'code1')You should check explain for "enhanced by dynamic partition elimination" and "exit this join step after the first row is found" If you really need to return the mese_cd, just replace "SELECT 'exists' WHERE ..." with "SELECT mese_cd FROM vt WHERE ...", but don't remove vt from the subquery.Dieter</description><pubDate>Sat, 05 Apr 2008 08:33:19 GMT</pubDate><dc:creator>dnoeth</dc:creator></item><item><title>RE: Query select..where..in on a partitioned table: partitions are not used</title><link>http://www.teradata.com/teradataforum/Topic11131-1-1.aspx</link><description>To eliminate partition, you must put constant constraint on partition column.when you use derived table, it will be treated as PPI and NPPI join without partitioning elimination.Is your purpose to limit the mese_cd dynamiclly?try it with macro parameters.</description><pubDate>Sat, 05 Apr 2008 05:36:57 GMT</pubDate><dc:creator>Jian</dc:creator></item><item><title>Query select..where..in on a partitioned table: partitions are not used</title><link>http://www.teradata.com/teradataforum/Topic11131-1-1.aspx</link><description>Hi all,I've a big problem with a "simple" select.I've the following table:ct toutput(mese_cd integer,field1_cd varchar(10), )UNIQUE PRIMARY INDEX XPKDT_OUTPUT ( MESE_CD , field1_cd ,   )PARTITION BY RANGE_N(MESE_CD BETWEEN 200401  AND 200412  EACH 1 ,200501  AND 200512  EACH 1 ,200601  AND 200612  EACH 1 ,200701  AND 200712  EACH 1 ,200801  AND 200812  EACH 1 );mese_cd is a field containing YYYYMM. The table contains about 500,000,000 recs.I need to verify if in that table exists data for a specific mese_cd.The query I need is something like:SELECT mese_cdFROM toutputWHERE field1_cd = 'code1'AND mese_cd = 200803SAMPLE 1This query uses partitions and is very fast (about 15 secs, 1/2 if the partition is empty).My problem is that the value 200803 is contained into a volatile table. I tried to modify it in this way:SELECT mese_cdFROM toutputWHERE field1_cd = 'code1'AND mese_cd = (SELECT min(mese_cd) FROM temporary_volatile_table)SAMPLE 1but it oirginates a full table scan on the toutput table (partitioning is not used).Also a simple test:SELECT mese_cdFROM toutputWHERE field1_cd = 'code1'AND mese_cd = (SELECT 200803)SAMPLE 1produces a full table scan..I tried also to create a working table partitioned like the toutput table, containing only the field mese_cd and only a row. I put these two tables in join but partitions are not used yet.Is there any easy suggestion to solve my problem? I've only to check if on the condition filed1_cd there are data available in a specific mese_cd.Any help will be apreciated :)</description><pubDate>Thu, 03 Apr 2008 07:16:23 GMT</pubDate><dc:creator>Alethesnake</dc:creator></item></channel></rss>