DotDragnet
May 23, 2012, 09:10:30 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: follow us on twitter @dotdragnet
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: slow searching views on Mysql....  (Read 512 times)
Scooby
Full Member
***
Posts: 163



View Profile Awards
« on: September 07, 2010, 02:18:41 PM »

Hi all.

I'm having some problems with slow searching of a view that unions two tables in mysql...

table one, is large with lookup contents for some 1.2m records
table two, same stucture but with local custom records - circa couple of hundred.

each get updated fairly regularly, they are unioned together to form one view to search from.

The user searches a view to return a record, but it is painfully slow. searching either table directly returns result relatively quickly, but searching the view can be minutes.

whats the best way to overcome this...? can I index views? I can't seem to find anything  relatively recent?

if not, is there some nifty php to use one query to search both tables one after the other.... will have a  unique identifier across both tables.

Thanks in advance.

Scoob

Logged
JasonD
Global Moderator
Hero Member
*****
Posts: 551



View Profile Awards
« Reply #1 on: September 07, 2010, 07:06:59 PM »

Two simple fast queries is generally faster than one complex slow query.

Would need to know more on how the tables are structured and what the view and/or other parts of the query say to suggest anything specific. An EXPLAIN query may help, or not.
Logged
Scooby
Full Member
***
Posts: 163



View Profile Awards
« Reply #2 on: September 08, 2010, 02:05:54 PM »

Cheers, I've gone for an if / else check for now, and I'll see how it goes.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!