@@ 492-510 (lines=19) @@ | ||
489 | * @param array $options |
|
490 | * @return int |
|
491 | */ |
|
492 | public function estimateRowCount( $table, $vars = '*', $conds = '', |
|
493 | $fname = __METHOD__, $options = [] |
|
494 | ) { |
|
495 | // http://msdn2.microsoft.com/en-us/library/aa259203.aspx |
|
496 | $options['EXPLAIN'] = true; |
|
497 | $options['FOR COUNT'] = true; |
|
498 | $res = $this->select( $table, $vars, $conds, $fname, $options ); |
|
499 | ||
500 | $rows = -1; |
|
501 | if ( $res ) { |
|
502 | $row = $this->fetchRow( $res ); |
|
503 | ||
504 | if ( isset( $row['EstimateRows'] ) ) { |
|
505 | $rows = (int)$row['EstimateRows']; |
|
506 | } |
|
507 | } |
|
508 | ||
509 | return $rows; |
|
510 | } |
|
511 | ||
512 | /** |
|
513 | * Returns information about an index |
@@ 394-409 (lines=16) @@ | ||
391 | * @param array $options |
|
392 | * @return int |
|
393 | */ |
|
394 | public function estimateRowCount( $table, $vars = '*', $conds = '', |
|
395 | $fname = __METHOD__, $options = [] |
|
396 | ) { |
|
397 | $options['EXPLAIN'] = true; |
|
398 | $res = $this->select( $table, $vars, $conds, $fname, $options ); |
|
399 | $rows = -1; |
|
400 | if ( $res ) { |
|
401 | $row = $this->fetchRow( $res ); |
|
402 | $count = []; |
|
403 | if ( preg_match( '/rows=(\d+)/', $row[0], $count ) ) { |
|
404 | $rows = (int)$count[1]; |
|
405 | } |
|
406 | } |
|
407 | ||
408 | return $rows; |
|
409 | } |
|
410 | ||
411 | public function indexInfo( $table, $index, $fname = __METHOD__ ) { |
|
412 | $sql = "SELECT indexname FROM pg_indexes WHERE tablename='$table'"; |