Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. Sure... if you have an integers table.
  2. Really? There's a DATE() function in mysql so that you do'nt need any of this magic.
  3. What does this have to do with mysql?
  4. There's a sticky on this topic.
  5. No only is it not a good idea, it's a terrible one.... leave the formatting to the WEB.
  6. Hmm... nothing wrong there...
  7. It doesn't matter where the parameter comes from... you need to pass it and sent to the SP.
  8. Run the equivalent select and show us the EXPLAIN.
  9. Not a problem -- but make you that you remove ALL the other indexes -- including the one just on ( user_id ) as well any other covering ones we made in the process -- otherwise you'll have extra overhead for no reason. I'd like to confirm what the final index that actually worked was... hard to tell from the expalin.
  10. paren = ( ) bracket = [ ] brace = { }
  11. As in: select memberType, COUNT(*) as cnt from members WHERE verified=1 GROUP BY memberType
  12. Yes, but even if it doesn't, the LIKE clauses in the column list are evaluated on a limited recordset (i.e. the matching rows), so it's neglible.
  13. That's nice... how about sharing your solution?
  14. The php refman is your friend.
  15. TLDR... can you simplify your issue?
  16. You don't select last_insert_id "from" anywhere. See here for a better way.
  17. Hmmm. still not ideal. Can you try a few things? 1) switch to ASC -- just for now. 2) try switching the order of the keys in the index, then try ASC/DESC.
  18. It is -- in the WHERE clause -- but you're already paid that performance penalty. And as mentioned earlier, drop UPPER() unless you've explicitly requested a case-sensitive collation.
  19. Well, you're not checking the return value of the mysql_query() call, nor capturing mysql_error() -- nor echoing the actual insert statement itself.
  20. Well, you're never pulling back the data... how do you know it's not being added?
  21. I'm hoping the optimizing handles this... even if it does, evaluating LIKE in the column list isn't expensive.
  22. Seriously? You're opening the block in the wrong place... write a proper if/else loop. edit: sending a PM to a moderator about basic PHP syntax in a mysql forum? bad idea.
  23. ALTER yourTable ADD INDEX user_history_datetime_user_id ( user_history_datetime, user_id ); Make sure this index is actually being used in the EXPLAIN -- otherwise, you'll have to force it.
  24. Then get LAST_INSERT_ID() from mysql -- php has a function for this, I think -- and pull back the newly inserted record.
  25. Well, of course it's slower... that's why mysql made the "right" choice. Much better to find 30K (0.5%) records and sort them, then to sort all 5M!!! I'd say that you could make a composite index on ( user_id, user_history_datetime ), but I'm not sure that it would work since you want DESC for the 2nd half of the key. In fact, try it 'backwards' -- composite index on ( user_history_datetime, user_id ).
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.