Remove table row count

QuestionsRemove table row count
Sunil asked 10 years ago

Hi,
I have 3 million row entries in my grid. To get the count of this number this query is generated
" SELECT count(*) as c FROM (SELECT * from table_name where column = 27 ) table_count "

This is taking all my server cores and is delaying my site load time.

Is there a way to optimize this????
If not how can I remove this call from the grid.

5 Answers
Abu Ghufran answered 10 years ago

Hello,

One option is to have index on this column.
Alternate option is to set:
$g->select_count = "…"; // your count record query except where clause.
$g->select_count = "select count(*) from table";

Sunil answered 10 years ago

Hi,
My Table is indexed.
$g->select_count = "select count(*) from table";
gives me count as 50 and I cant access anything after 50.

Is there a way to remove this?

Abu Ghufran answered 10 years ago

Hello,

I can't understand the issue. If count is correct, how can you access after 50.
Please explain little further what exactly is the issue.

Sunil answered 10 years ago

Hi,
here is the link for a photo without select_count line in my code

View post on imgur.com

Here is the link for a pgpto with select_count line in my code

View post on imgur.com

I put the followiung code in the grid
$g->select_count = "SELECT count(*) from $table_name where client = " . $clients;

I have put this below my select_command
$g->select_command = "SELECT * from $table_name where client = " . $clients;

Abu Ghufran answered 10 years ago

Ok, i got the issue.

Change count query to …

$g->select_count = "SELECT count(*) as c from $table_name where client = " . $clients;

Alias 'c' should be given for custom count sql.

Your Answer

4 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?