|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.38 2002/06/20 20:29:26 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.39 2002/07/31 17:19:51 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -107,6 +107,11 @@ typedef struct |
107 | 107 | #define swapInt(a,b) do {int _tmp; _tmp=a; a=b; b=_tmp;} while(0) |
108 | 108 | #define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0) |
109 | 109 |
|
| 110 | + |
| 111 | +/* Default statistics target (GUC parameter) */ |
| 112 | +int default_statistics_target = 10; |
| 113 | + |
| 114 | + |
110 | 115 | static int elevel = -1; |
111 | 116 |
|
112 | 117 | static MemoryContext anl_context = NULL; |
@@ -384,7 +389,7 @@ examine_attribute(Relation onerel, int attnum) |
384 | 389 | VacAttrStats *stats; |
385 | 390 |
|
386 | 391 | /* Don't analyze column if user has specified not to */ |
387 | | - if (attr->attstattarget <= 0) |
| 392 | + if (attr->attstattarget == 0) |
388 | 393 | return NULL; |
389 | 394 |
|
390 | 395 | /* If column has no "=" operator, we can't do much of anything */ |
@@ -425,6 +430,10 @@ examine_attribute(Relation onerel, int attnum) |
425 | 430 | stats->eqopr = eqopr; |
426 | 431 | stats->eqfunc = eqfunc; |
427 | 432 |
|
| 433 | + /* If the attstattarget column is negative, use the default value */ |
| 434 | + if (stats->attr->attstattarget < 0) |
| 435 | + stats->attr->attstattarget = default_statistics_target; |
| 436 | + |
428 | 437 | /* Is there a "<" operator with suitable semantics? */ |
429 | 438 | func_operator = compatible_oper(makeList1(makeString("<")), |
430 | 439 | attr->atttypid, |
@@ -466,14 +475,14 @@ examine_attribute(Relation onerel, int attnum) |
466 | 475 | * know it at this point. |
467 | 476 | *-------------------- |
468 | 477 | */ |
469 | | - stats->minrows = 300 * attr->attstattarget; |
| 478 | + stats->minrows = 300 * stats->attr->attstattarget; |
470 | 479 | } |
471 | 480 | else |
472 | 481 | { |
473 | 482 | /* Can't do much but the minimal stuff */ |
474 | 483 | stats->algcode = ALG_MINIMAL; |
475 | 484 | /* Might as well use the same minrows as above */ |
476 | | - stats->minrows = 300 * attr->attstattarget; |
| 485 | + stats->minrows = 300 * stats->attr->attstattarget; |
477 | 486 | } |
478 | 487 |
|
479 | 488 | return stats; |
|
0 commit comments