Support » Plugin: Search Meter » Duplicate entry ‘2018-05-01’ for key ‘PRIMARY’

  • Resolved cim

    (@cim)


    Query Monitor is showing me database errors because the key is the same when you look up the same thing over and over again. Why not use update_option() instead of putting the counter in its own table?

    INSERT INTO 'wp_searchmeter' ('terms','date','count','last_hits') 
    VALUES ('tacos', UTC_DATE(), 1, 6)
    
    apply_filters_ref_array('the_posts');
    
    Duplicate entry 'tacos-2018-05-01' for key 'PRIMARY'
    • This topic was modified 1 year, 4 months ago by  cim.
Viewing 1 replies (of 1 total)
  • Plugin Author Bennett McElwee

    (@bennettmcelwee)

    This is expected: I try to insert each search in the table and then if that fails (because that search has already been made that day) I update instead. I have a very low-priority plan to switch to using INSERT … ON DUPLICATE KEY UPDATE to do it all in one step.

    Searches should go in their own table rather than cluttering up the options table (which is for options, after all). It would make it tricky (and very inefficient) to manage the number of saved searches.

Viewing 1 replies (of 1 total)
  • The topic ‘Duplicate entry ‘2018-05-01’ for key ‘PRIMARY’’ is closed to new replies.