Jump to content

Scorpy

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Scorpy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. tb1.col1, tb1.col2 and tb1.col3 are all indexed, it shows them as possible keys but just doesn't use any of them, is there something i'm not understanding or that I'm missing?
  2. The explain on that shows the exact same as my first one with the left joins, a full tablescan for tb1 (NULL for keys), and eq_ref for the other tables using primary key.
  3. The above should explain what's happening clearly, to fix just increase your DECIMAL(M,D) to what you need.
  4. Try replacing: $sql="SELECT id,username FROM 'Admin' WHERE 'username'='$user' AND 'password'='$pass'"; With: $sql="SELECT id,username FROM Admin WHERE username='$user' AND password='$pass'";
  5. I have a query that has 3 left joins on it from other tables, i'll write an example below (MySQL 5.1.32).. (All conditions are key'd) SELECT tb1.*, tb2.*, tb3.* tb4.* FROM tb1 LEFT JOIN tb2 ON tb1.col = tb2.col LEFT JOIN tb3 ON tb3.col = tb1.col LEFT JOIN tb4 ON tb4.col = tb1.col WHERE tb1.col1 = value OR tb1.col2 = value OR tb1.col3 = value ORDER BY tb1.col4 ASC The problem is that because I use an OR in the where clause, it does a full table scan, so I wondered if doing this within a union would be faster? Example: ( SELECT tb1.*, tb2.*, tb3.* tb4.* FROM tb1 LEFT JOIN tb2 ON tb1.col = tb2.col LEFT JOIN tb3 ON tb3.col = tb1.col LEFT JOIN tb4 ON tb4.col = tb1.col WHERE tb1.col1 = value ) UNION ALL ( SELECT tb1.*, tb2.*, tb3.* tb4.* FROM tb1 LEFT JOIN tb2 ON tb1.col = tb2.col LEFT JOIN tb3 ON tb3.col = tb1.col LEFT JOIN tb4 ON tb4.col = tb1.col WHERE tb1.col2 = value ) UNION ALL ( SELECT tb1.*, tb2.*, tb3.* tb4.* FROM tb1 LEFT JOIN tb2 ON tb1.col = tb2.col LEFT JOIN tb3 ON tb3.col = tb1.col LEFT JOIN tb4 ON tb4.col = tb1.col WHERE tb1.col3 = value ) This way instead of using the OR value, each where condition went inside of it's own union, the thing that I'm confused about is that the first time I ran this it came up with 0.04 sec time, on a small table, whereas the first one showed at 0.00 sec, but all of the 'types' on the union showed as either ref or eq_ref which isn't a full scan, except for the union result select_type. So I was wondering if anyone could explain this to me and point me in the right direction please.
  6. I don't believe it is and I have spent a few hours searching to try and find out, but for just incase I've missed something I figured best to post on here and just ask. Is it possible to run a file that's local on the server from within mysql? Such as from a stored procedure for instance. I'm using the mysql event scheduler that runs a stored procedure, I'm hoping to have that stored procedure run a script to handle what I need instead of having to place a row into a table to be executed when the next page load is.
×
×
  • 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.