WordPress.org

Ready to get started?Download WordPress

Forums

post-views
can you optimize plugin to reduce database query? (1 post)

  1. Nadiamode
    Member
    Posted 2 years ago #

    I think this plugin run sql query more than others similar plugin, but this plugin has many functions ex. latest views, views by month, year etc. it good and I love it

    But some function does not necessary and may make sql work too much ex. robot log also view and preview, I know it not same but is it similar ? do we need to show both view and preview or we need only one?

    Another thing is plugin use 3 database table

    wp_post_views_history
    wp_post_views_realtime
    wp_post_views_summary

    Can plugin optimize to save all data into one or two post-metadata (1 row) ?

    example

    $viewdata = array (
      'post_view_realtime' => array (
                       'post_id' => 2,
    	           'output_type' => 'content',
                       'year_id' => 2012,
    ),
      'post_views_history' => array (
                       'view_type' => 'normal',
                       'post_id' => 2,
    	           'post_views_today' => array (-1,0,1,0,0,0),
                       'post_views_week' => 45,
    	           'post_views_month' => 260,
                       'post_views_year' => 3560,
    ),
      'wp_post_views_summary' => array (
                       'summary' => 'normal_views',
                       'summary_type' => array (
                                          'type1' => 'normal_views',
                                          'type2' => 'robot_views',
                                          'type3' => 'all_views',
    )
    )
    );

    We combine all data that use in 3 database table into 1 meta post for specific post id (1 post per meta 1 row)
    After serialize array data so plugin add all data to post meta

    add_post_meta(500, 'post-viewsss', $viewdata );

    Now plugin keep data only 1 row like this

    a:3:{s:18:"post_view_realtime";a:3:{s:7:"post_id";s:1:"2";s:11:"output_type";s:7:"content";s:7:"year_id";s:4:"2012";}s:18:"post_views_history";a:6:{s:9:"view_type";s:6:"normal";s:7:"post_id";s:1:"2";s:16:"post_views_today";a:6:{i:0;s:2:"-1";i:1;s:1:"0";i:2;s:1:"1";i:3;s:1:"0";i:4;s:1:"0";i:5;s:1:"0";}s:15:"post_views_week";s:2:"45";s:16:"post_views_month";s:3:"260";s:15:"post_views_year";s:4:"3560";}s:21:"wp_post_views_summary";a:2:{s:7:"summary";s:12:"normal_views";s:12:"summary_type";a:3:{s:5:"type1";s:12:"normal_views";s:5:"type2";s:11:"robot_views";s:5:"type3";s:9:"all_views";}}}

    I know your plugin has features more than other plugin, some other post view plugin store only view count number in post-meta so they can view only views, lease views, most views but cannot sort like your plugin

    I also dont know how to write plugin but just need to give some suggestion that plugin should optimize for wordpress performance too, I dont want to see good plugin like this go to be crazy same some plugin ex. GD Star Rating that eat many query and use many table (GD Star run around 30-50 query while normal wp blog (single page use only 17-19 query))

    I dont't know maybe some function need to store data in separate table, it okay but if there're other data that can combine into 1 postmeta row or 2 or 3, I think its greater than split data and use many table + many row

    If we have only 1-2 postmeta so your plugin can huge reduce many sql query also make wordpress performance better

    http://wordpress.org/extend/plugins/post-views/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags