midbar: (Default)

Originally published at Moishe Beshkin. Please leave any comments there.

In order to show paging of our resources, we use LIMIT in our MySQL query. I met some scalability issues, while using the simplest way of getting total number of rows.

The simplest way to get total number of rows in you MySQL query is to run the following construction:

$query = mysql_query("SELECT COUNT(*) FROM table WHERE name LIKE 'a%'");
$result = mysql_fetch_array($query);
$total_num_rows = $result[0];

$query1 = mysql_query("SELECT * FROM table WHERE name LIKE 'a%' LIMIT 0,50");
/* HERE IS YOUR CODE PARCING THE RESULTS OF MAIN QUERY */

It works pretty good and fast if you have less than 100 results.

I tried this structure on a table with 1000 rows.
It takes the same time to return a page as if I ran query without LIMIT.
I found solution on this page MySQL: Get total number of rows when using LIMIT.

$query = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE name LIKE 'a%' LIMIT 0,50");
$query_count = mysql_query("SELECT FOUND_ROWS()");
$result = mysql_fetch_array($query_count);
$total_num_rows = $result[0];

/* HERE IS YOUR CODE PARCING THE RESULTS OF MAIN QUERY */

The same number of rows as it was in the first example, was returned in less than a second.

midbar: (Default)

Originally published at Moishe Beshkin. Please leave any comments there.

This article was published in Russian on my blog midbar.livejournal.com. Now, I decided to translate it to English and publish here.
This tutorial was written, due to the reason that there was no much information about Banklink (Pangalink) in Russian and English. So, here the document, how to set up BankLink connection, what it is in general and what are the specifics.

Read the rest of this entry »

midbar: (Default)

Originally published at Moishe Beshkin. Please leave any comments there.

22 December, 2010.
my lecture about Man 2.0 on DevClub.eu meeting.


Watch live video from Devclub.eu on Justin.tv

midbar: (Default)

Originally published at Moishe Beshkin. Please leave any comments there.

This lecture occurred on December, 2009 in Tallinn, Estonia.
Lecture topic was dedicated to the idea that WEB 2.0 was not invented in 21st century, but is a normal way of thinking of a human being. And as a result WEB 2.0 technology, just gives and instant access to the responses of readers.

Here is the video from the meeting

Read the rest of this entry »

Profile

midbar: (Default)
midbar

March 2012

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 26th, 2017 12:45 pm
Powered by Dreamwidth Studios