I have the following query.
SELECT DISTINCT propertylist.propertyid
,propertylist.price
,propertylist.publicremarks
,address.addressline1
,address.streetaddress
,address.city
,address.postalcode
,alternateurl.maplink
,building.bathroomtotal
,building.bedroomtotal
,building.constructeddate
,building.sizeinterior
,building.type
,building.basementfeatures
,building.basementtype
,building.constructionstyleattachment
,propertylist.ammenitiesnearby
,propertylist.features
,propertylist.transactiontype
,propertylist.lastupdated
,propertylist.communityfeatures
,land.acreage
FROM propertylist
,address
,building
,alternateurl
,land
WHERE propertylist.propertyid = address.propertyid
AND address.propertyid = building.propertyid
AND building.propertyid = alternateurl.propertyid
AND alternateurl.propertyid = land.propertyid
I want to know the total number of records that will be derived from this query so that i can implement paging in my website. If i try to execute this without 'limit' it takes so much time and the execution time runs out. The result of Explain sql is
Generation Time: Feb 21, 2015 at 01:06 PM
Generated by: phpMyAdmin 4.2.7.1 / MySQL 5.5.39
SQL query: EXPLAIN SELECT DISTINCT COUNT(*) FROM propertylist , address , building , alternateurl ,land WHERE propertylist.propertyid = address.propertyid AND address.propertyid = building.propertyid AND building.propertyid = alternateurl.propertyid AND alternateurl.propertyid = land.propertyid;
Rows: 5
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE alternateurl ALL NULL NULL NULL NULL 12947
1 SIMPLE address ALL NULL NULL NULL NULL 13338 Using where; Using join buffer
1 SIMPLE building ALL NULL NULL NULL NULL 13389 Using where; Using join buffer
1 SIMPLE propertylist ALL NULL NULL NULL NULL 13614 Using where; Using join buffer
1 SIMPLE land ALL NULL NULL NULL NULL 13851 Using where; Using join buffer