[Solved] Why those two questions gets diffrent results?

EverSQL Database Performance Knowledge Base

Why those two questions gets diffrent results?

Through: https://developers.facebook.com/tools/explorer if I ask with use of graph api:

get: ?ids=http://localhost/gbi-bieganie.pl/2013/03/20/kolacja-po-wieczornym-bieganiu-tak-czy-nie/

I get different result for the same url, than with use of fql query:

SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count 
FROM link_stat 
WHERE url = "http://localhost/gbi-bieganie.pl/2013/03/20/kolacja-po-wieczornym-bieganiu-tak-czy-nie/";

Can anybody explain me why those queries differ, and how should I do one query that gets correct number of likes of an url, number of its comments, and number of shares?

How to optimize this SQL query?

The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:

  1. Description of the steps you can take to speed up the query.
  2. The optimal indexes for this query, which you can copy and create in your database.
  3. An automatically re-written query you can copy and execute in your database.
The optimization process and recommendations:
  1. Create Optimal Indexes (modified query below): The recommended indexes are an integral part of this optimization effort and should be created before testing the execution duration of the optimized query.
Optimal indexes for this query:
ALTER TABLE `link_stat` ADD INDEX `link_stat_idx_url` (`url`);
The optimized query:
SELECT
        link_stat.url,
        link_stat.normalized_url,
        link_stat.share_count,
        link_stat.like_count,
        link_stat.comment_count,
        link_stat.total_count,
        link_stat.commentsbox_count,
        link_stat.comments_fbid,
        link_stat.click_count 
    FROM
        link_stat 
    WHERE
        link_stat.url = 'http://localhost/gbi-bieganie.pl/2013/03/20/kolacja-po-wieczornym-bieganiu-tak-czy-nie/'

Related Articles



* original question posted on StackOverflow here.