# Archives of the TeradataForum

## Message Posted: Mon, 26 Jan 2009 @ 13:46:27 GMT < Last>>

 Subj: Some basic but interesting questions on COLLECT From: Srihari Duddukuru

Hi There,

I need some important inputs on the way we collect statistics. Below is the example

I have 4 tables, each with a single column Primary Index (assume all have same data volume ~ 5 million rows). Below are the tables and their PIs

```     Table A (PI=x1)
Table B (PI=y1)
Table C (PI=y1)
Table D (PI=x2)
```

And, here is the query

```     Select A.x1..., B..., C...., D...
from
A, B, C, D
where
A.x1=b.x1
and
A.x2=D.x2
and
A.x3=100
and
A.x4='BMW'
and
B.y1=C.y1
and
b.y2 in ('SFO','LAX')
and
C.z1 = 11
and
C.z2 = '*'
and
D.r1 <> 'PAK'
and
D.r2 = '\$135000';
```

Now, the queries follows

1. In the above query, what is the best way to collect stats? Is it on all columns individually? Like..

```     STATS ON A (x1)
STATS ON A (x2)
STATS ON A (x3) ....
```

2. Is it good to collect stats on combination of joining columns and filter columns separately as given below?

Assume, we have stats on PI already

```     STATS ON A (x1,x2)
STATS ON A (x3,x4)
STATS ON B (y2)
STATS ON C (z1,z2)
STATS on D (r1,r2)
STATS on D (x2) ...
```

3. Or, combination of all columns of a table is good?

```     STATS ON A (x1,x2,x3,x4)
STATS ON B (y1,y2)
STATS on C (z1,z2,y1)
STATS on D (x2,r1,r2)
```

4. Since there is an inequality condition on D.r1 (D.r1 <> 'PAK'), how the stats should be?

5. Incase conditions the columns D.r1 and D.r2 are ORed together, then how the stats should be?

```     ...
and
(
D.r1 <> 'PAK'
OR
D.r2 = '\$135000'
)
```

In short, Is it always good to collect stats on individual columns or combination of columns based on joining and filter conditions? In case of later, what is the best way of grouping the columns?

Regards,

Hari < Last>>

Attachments

Library

Quick Reference

Archives

Sample Index

 2016 2007 2015 2006 2014 2005 2013 2004 2012 2003 2011 2002 2010 2001 2009 2000 2008 1999

2009 Indexes

 Jan Jul Feb Aug Mar Sep Apr Oct May Nov Jun Dec

 Top Home Privacy Feedback
{"ft_lang_label":"__label__en","ft_lang_prob":0.7966536,"math_prob":0.8316539,"size":1718,"snap":"2019-13-2019-22","text_gpt3_token_len":551,"char_repetition_ratio":0.1411902,"word_repetition_ratio":0.018691588,"special_character_ratio":0.35215366,"punctuation_ratio":0.21460177,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98860615,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-25T04:36:01Z\",\"WARC-Record-ID\":\"<urn:uuid:42f3dd50-a2ec-491e-a873-31762e664443>\",\"Content-Length\":\"13042\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bf9bf462-c5d2-4075-ab86-02e6abc1787a>\",\"WARC-Concurrent-To\":\"<urn:uuid:9e8256bd-e789-4faf-b840-0dda5653b6b1>\",\"WARC-IP-Address\":\"209.188.7.198\",\"WARC-Target-URI\":\"http://teradataforum.com/teradata/20090126_134627.htm\",\"WARC-Payload-Digest\":\"sha1:2ABSX7V5J4OW5B6MHFZRTOC7RJ447U3V\",\"WARC-Block-Digest\":\"sha1:S5EOIZG3K5UQBHXYVUUOTGKDOQ635NCO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912203548.81_warc_CC-MAIN-20190325031213-20190325053213-00432.warc.gz\"}"}