mvnobrega's avatar

Number of records in database and count() is different [ SOLVED ]

In my database there is this: (68427 total, The query took 0.0006 seconds.)

That is, there are 68,427 records

But when I call pagination or even Table::all()->count()

The result is 76,523

by the inclusion id I can't trust as many have been erased over time. Last ID is 70,917

by pagination the result checks, but my finger bank shows a value below what it really should have

Why does this difference occur?

0 likes
16 replies
mvnobrega's avatar

@sr57

I don't know if I'm doing it right, but it didn't bring me any useful information

mvnobrega's avatar

@sr57

select * from `livros` where `id` > 0

Executing this command in the database and the result was the same as for pagination and count(), that is: 0 - 24 (76523 total, A consulta demorou 0.0106 segundos.)

sr57's avatar

@mvnobrega

So where come your first number 68,427 ? This should be wrong ...

1 like
mvnobrega's avatar

@sr57

when I open the database, this value already appears, and the paging number of the database, if I add it up, it matches the number that it is displaying. However, I have just noticed that the paging of the database is not continuous. Look: https://imgur.com/TuQOwsj

when I open the database, this value already appears, and the paging number of the database, if I add it up, it matches the number that it is displaying. However, I have just noticed that the paging of the database is not continuous. Look:

But when I consult the pagination, it doesn't seem to have any errors, they show all

sr57's avatar

"when I open the database," .... which tool are you using?

can you run queries directly in the db?

select count(*) from livros;
1 like
mvnobrega's avatar

@sr57

i am opening phpmyadmin from cpanel

select count(*) from livros return: count(*) 76523

mvnobrega's avatar

@sr57

yes, but it's weird that the database shows less than the actual value. Why is this happening?

sr57's avatar

@mvnobrega

It's not the database, it's the tool you are using and I don't know it. (Personally I nexer use such tool, Laravel and direct cde in the db)

sr57's avatar

@mvnobrega

can be an explanation and confirm why it's better to use right query in the db.

1 like

Please or to participate in this conversation.