Blog Stats & SQL Question..

Added blog stats on the left menu, takes forever to load.. like 20 seconds. (lol, we have reached the point that 20 seconds is forever).
On a second thought I’m trying to mess with the wordpress database… with SQL.. nothing fancy.. using MyAdmin (MyPHPSQL)..

I want to IF email = “whatever” insert “data” into “correct column”
Can anybody give me the correct syntax, I can pick the right tables without to much problems.. but the if thens in sql.. are a bit rusty.. and I need to get it right the first time.

This entry was posted in Announcements, Cool Tech & Web stuff, Hilarious. Bookmark the permalink.

27 Responses to Blog Stats & SQL Question..

  1. Christopher says:

    INSERT INTO wp_comments
    (comment_author_url)
    SELECT ‘www.url.com’
    WHERE comment_author_email = “email@email.com”;

    whatta think… (be gental..)

  2. Christine says:

    It’s soooooooo sexy when he talks like a computer geek. :*

  3. Haas says:

    I guess the Blog Stats page takes so long is coz of the size of the database. The queries I imagine you will be passing to get those details will themselves take a while to finish…
    This page took 373 queries. 16.545 seconds of computer time to create.
    Now you can try adding an index or two try the email column coz ur passing queries on it… Probably a BTree index if MySql supports it…
    Other than that you cant do much… If you really want to speed up stuff I hv an idea but it involves a lot of work and touching WordPress internals…

  4. Christopher says:

    Haas,
    Actually we have some people who would like the URL’s of there blogs added to all their comments and also people like ben and aj have multipl names in our list I was thinking of trying to combine them.

    Hit me thru the wordpress contact us, I’m interested in hearing how we could speed everything up… altho as long as we are running the polls, and the top ccommenter, latest commenter lists.. thing are only going to get so fast.. plus the database is starting to get some size to it.

  5. Haas says:

    Oh ok I see, I guess I was Solving the wrong problem :P
    Firstly MySql does not allow you to update one table using data from another table… plus u got to be making an update not an insert (hope ur doing what I think ur doing :P )
    This will require you to manually make the changes to the wp_comments table…
    A query such as:
    UPDATE wp_comments
    set comment_author_url = “http://url.com”
    where comment_author_email = “email@domain.com”;
    PS: U will hv to do it for each one of ur commenters… Conisdering the prob is with Ben and Aj’s details it will take u just 2 queries….
    VERY IMPORTANT: Dude backup ur data(I know u already knew that) coz i hv not tried the query on my sys… can test it and tell u in a while if u want.

  6. aJ says:

    #3 is correct. You only need to update not insert.
    Btw sorry for the multiple meta info :\”> but it was all due to me shifting to my own domain with it’s own email address. The earlier one was shared with a few friends

  7. Lei says:

    ah computer gods ^:)^

  8. Christopher says:

    Great advice guys.. .now..

    UPDATE wp_comments
    SET comment_author_email = ‘aj_new_email’
    WHERE comment_author_email = ‘aj_old_email’

    Do you running this query could be deadly?

  9. Haas says:

    Nope, I wont be really worried but create a copy of ur db (atleast that table) and run it on that first(u dont want to change the email id of everyone to aj_new_email by mistake) :-w
    But just running…
    SELECT * FROM wp_comments
    WHERE comment_author_email = ?aj_old_email?
    will tell u which tuples its changing so a bit more safer… check the output and if its only Aj’s comments… :d/ then go ahead :) >-

  10. Christopher says:

    dude.. I think it’s ” not ‘ ?

  11. Christopher says:

    Ahh.
    Haas – AJ
    Thanks for the good information the top 20 commenters now make sence.. Ben your comments are now combined under on user name! :) All is right in the blogsphere this morning.

  12. aJ says:

    Thank Christopher.. I did not know I’d commented so much :)

  13. Haas says:

    One small fix dude… My blog is at “blog.chandrahasa.com” I moved to a few weeks ago so can u plz make the change in the top commenters page :)
    Sorry for the trouble

  14. Matt says:

    215 queries does seem like an awful lot for a relatively straightforward page… and I was thinking to myself today how slow the site is…

  15. Christopher says:

    Lei, I think your fixed up also..

  16. Lei says:

    Goodie! Thanks, Chris! :)

  17. Keith says:

    Didn’t I tell you to have faith in my boy lei? ;) Plu sI’d say you’re fixed…You went from 8 comments to 72 over night :d

  18. Lei says:

    aight! 72 comments in less than 24 hours is not at all bad ;)
    now my next job for christopher is…. :-? :)

  19. Christopher says:

    Lei, you will have to give me a couple days.. Christine is now loading me up with projects on CvC.. ;)

  20. Keith says:

    Lei you don’t want to gothere with chris ;) …your finace’ might get mad! :d

  21. Lei says:

    :o lol! i read it as “finance” the first time, and i thought, huh? slow me, hehe… dont worry, the job i have for him is just a change of avatar, but i can wait. no hurry… ;)

  22. Keith says:

    ohhh ok well that safe… ;) you can actually change that on you own..make it yourself and register it then you can put it in under your preferences.
    http://www.gravatar.com/

  23. Christine says:

    Thank God for Lei… now Christopher can never again say *I’m* the most demanding woman he’s ever met… ;-)

  24. Christopher says:

    Lei,
    Have you checked out http://www.gravatar.com if you have one of those.. I THINK it will overridge your avatar here.. and it will work everywhere on the internet.. but if not drop me an email at Christopher@chrisvschris.com with the avatar u were interested in.. altho be warned I am thinking about changing that system due to the slowness of the site.

  25. Lei says:

    Hehe, Christine… I think “demanding” is one of the men’s favorite words to describe women. I’ve been called that many times, I’m used to it ;)

  26. Lei says:

    Christopher, yes I think I’ll just email you the avatar I have in mind. Tnx!:)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>