Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




UNION And Optimization?


My question is about a UNION query to deal with an (annoying) JOIN
over two tables. I am joining over a double column primary key (where the
order of the columns can be changed). This is so slow using a
join, but very fast using a union. How come this is? Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
UNION, Individually Works Fine, But Not In Union
Well, I am using an UNION, and while both of the queries works fine while used individually, they don't work while in the UNION.

Here is the code -

PHP

(
SELECT *
FROM job
WHERE date_fin !=0000-00-00
ORDER BY date_fin ASC
)
UNION (
SELECT *
FROM job
WHERE date_fin =0000-00-00
ORDER BY date_creation ASC
)

What do u think guys?

Note : MySQL version 4.1.21

Note : Not working means, this part is not working => 'ORDER BY date_fin ASC', means, the returned results are not ordered as I want.

MySQL doc. tells,

To apply ORDER BY or LIMIT to an individual SELECT, place
the clause inside the parentheses that enclose the SELECT:

(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)
UNION
(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);

Optimization
I'm running MySQL 5.0.19 (windows), and running mostly well, but in
some cases seems too slow. I've been optimizing SQL as much as
possible, indexing important fields, using OPTIMIZE TABLE to clear out
deleted records, etc. I would also like to adjust the my.ini settings
to make sure things are set there to be as optimal as possible.

My
question is, when I look at the statistics in SHOW STATUS, is there any
guide for what to look for as far as what's running optimally or needs
improvement? I'm connecting to MySQL from ColdFusion.

Optimization
I have 2 tables that I join about (150,000 rows each)

in my where clause I have a statement that says ... t2.franchise!=3

now sometimes when the query is generated, there is a statements t1.feed=4

Now I know that when there is a feed 4, the franchise will never be 3

So, does taking out that extra franchise statement when I know it does not matter speed things up? I have about enough of these type of things that if would case me 3 or 4 conditionals in every query. I can just take care of them in php, but I will not waste my type if it will not matter.

Optimization
I wanted to ask information to you on like optimizing MySQL, in how much in the event that I illustrate I have found to you of 'the anomalous' performances.

In the first place I have intalled MySQL 5.0.11. I have a table 'Anag' with 31 fields, primary key Id AutoInc and one key univoque for Desc+Indirizzo+Localita.

If from the Query Browser I execute 'select cod, descr from anag' come extracted 150000 records in 4 second ones. If instead I execute 'select cod, descr from anag order by descr' the 150000 records they come extracted in 100 second ones.

I have tried to create a single index on the field descr, but the times do not change. The times are not change to you after to have made the 'Check Tables' and 'Optimize Tables'.

Not creed that is normal school that the clause Order by on an indexed field me must cost therefore a lot. What I could modify in order to improve the performances?

Optimization
I have a MySQl database on the backend of an Access front end where multiple users update client information as calls come into the company.  All of the data is now linked into Access from linked tables.  

The problem is the response time when they are adding records.  It's not a heavy volume at all but there are about 10 users updating at the same time.  All users are set up under one username thread, as this was an easier way to set up the ODBC connection. (Is that the right way to go?)  

My question is...what are the optimization parameters that I should be adjusting?  I am sure it has to do with the cache and the amount of memory being met for disk writes.  (Is this correct?)

Optimization
I need to get the last entry of a table, so I'm using the following query:

SELECT * FROM table WHERE (some conditions) ORDER BY date DESC LIMIT 0,1

This seems a little bit stupid... Does anybody know an another way to do that? Can I keep a ordered table and than avoi the use of "order by"? If yes, how can I do that?

Optimization
I read at MysQl.com about Explain SELECT, it says at then end of a =
paragraph to optimize your query, using filesort or temporary, but I =
went to MySQL search engine no luck on finding them, can someone explain =
me both type.

**What i'm doing, since I'm using mysql for a program***=20
**I execute a query=20
**when i get the query , I'm putting everything in a hash dbm
**Then i read the line i want to, I'm doing so because it is easy to =
overwritte info on the dbm which i really want to.

My.ini Optimization
I'm having some performance issues that seem to be MySQL related.

I am running W2KAS IIS, PHP 5.1.4 and MySQL 5.0.21. Memory or CPU speed do not appear to be the problem.

I'm running a phpBB forum and having difficulties editing posts, the install of phpBB seems to be perfectly okay, but when editing posts it either takes forever and times out or just comes up with a blank page after a couple of minutes.

I notice that mysqld-nt.exe will use up about 30-50% of cpu time when this is going on. Code:

Optimization
I have a MySQl database on the backend of an Access front end where multiple users update client information as calls come into the company.  All of the data is now linked into Access from linked tables.  

The problem is the response time when they are adding records.  It's not a heavy volume at all but there are about 10 users updating at the same time.  All users are set up under one username thread, as this was an easier way to set up the ODBC connection. (Is that the right way to go?)  

My question is...what are the optimization parameters that I should be adjusting?  I am sure it has to do with the cache and the amount of memory being met for disk writes.  (Is this correct?)

Optimization
i have a little complex query that involves sub queries upto three levels. now thing is that , i think, mysql evaluates the sub queries every time that query is evaluated, whereas, i know that results for the third and 4th level queries are same for some number of queries. can we force mysql to store the result of the subqueries to be used later, instead of reexecuting the query.i studied mysql query optimization but, finally concluded is that things over there are just how mysql optimizes queries, not how can we optimize the query to be performed better. any resources for query optimization, i mean good resources ?

MySQL Optimization??? Help!
im recently been suspended daily by my hosts, saying that im causing a high load on my server with around 500,000 requests daily!!!

Now they are saying "usual" reasons for this are databases, and i run a big phpbb forum. Unfortunatly my knowledge of MySQL is limited, very limited in fact, so i cannot make optimization changes what-so-ever. Iv asked for help at phpbb official support......no answer.... however from browsing, i found "modded" forums can sometimes cause over 100 requests per post, but it can be optimized...... so im looking for help, tips, or anything you guys can give me to combat or fight this problem!

I have access to phpmyadmin, the forum db size is around 100mb, 5,000 members, not all active!

and i also run a topsite list!

if i cannot do this myself im willing to let a mysql expert have a look round, see if thye can fix this, and ill pay them to do so, if must be but my budget is limited, otherwise id just move to a new host


Query Optimization Help Please
I am traversing over a table that holds "adspaces" via two aggregate functions to get the total number of adspaces for a publisher and the number of approved ones. The query is very slow and there must be a way to convert the subqueries into joins or anything else. Would really appreciate it if someone could give me a hand.

PHP

$sqlQuery =      "SELECT a.*, " .
                       "(SELECT COUNT(b.id) FROM ".DB_TABLENAME_ADSPACE." AS b " .
                          "WHERE b.publisher        = a.publisher " .
                           "AND b.status_approval <> '" . STATUS_WAITING . "' " .
                          ") AS num_adspaces_total, " .
                       "(SELECT COUNT(c.id) FROM ".DB_TABLENAME_ADSPACE." AS c " .
                          "WHERE c.publisher        = a.publisher " .
                            "AND c.status_approval  = '" . STATUS_APPROVED . "'" .
                         ") AS num_adspaces_approved " .
                  "FROM `" . DB_TABLENAME_ADSPACE . "` AS a "            
                . "WHERE (a.status_changes  = '" . STATUS_WAITING . "' "
                .     "OR a.status_approval = '" . STATUS_WAITING . "') "
                .    "AND a.watchlist       != '" . WATCHLIST_WAITING . "' "
                . ";";

DB Structure/optimization?
I was wondering if anyone could recommend any REALLY good articles/tutorials/whatever on good database structures or optimization?

SQL Query Optimization Help Please
SELECT sess.id, u.id AS user_id FROM
(SELECT s.id, s.session_id
FROM `ll_session` AS s
WHERE s.online = &#3912;'
) AS sess
LEFT JOIN `ll_user` AS u ON (sess.session_id = u.last_visit)
What I have so far is this:

SELECT s.id, s.session_id, u.id AS user_id FROM `ll_session` as s

LEFT JOIN `ll_user` AS u ON (s.session_id = u.last_visit)
WHERE s.online = &#3912;'

Query Optimization
On one of our other production servers we have a write heavy database, which currently seems to be utilizing 80% CPU usage and one of our queries seems to be taking quite some time to actually execute.

SELECT *, CONVERT_TZ(date_trade,'GMT','Australia/Sydney') AS date_trade FROM trade_messages WHERE processed = 'NO' ORDER BY ftid ASC LIMIT 200;

200 rows in set (6.33 sec)
The ORDER BY is a necessary part of the query, we could most likely sort this within the code, however we still experience a 3 second query removing the ORDER BY and still seems to scan a lot of rows.

mysql> EXPLAIN SELECT *, CONVERT_TZ(date_trade,'GMT','Australia/Sydney') AS date_trade FROM trade_messages WHERE processed = 'NO' ORDER BY ftid ASC LIMIT 200;
+----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-----------------------------+
| 1 | SIMPLE | trade_messages | ref | processed,searchArgs,proc | processed | 1 | const | 112146 | Using where; Using filesort |
+----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-----------------------------+
1 row in set (0.66 sec)

EXPLAIN SELECT *, CONVERT_TZ(date_trade,'GMT','Australia/Sydney') AS date_trade FROM trade_messages WHERE processed = 'NO' LIMIT 200; +----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-------------+
| 1 | SIMPLE | trade_messages | ref | processed,searchArgs,proc | processed | 1 | const | 111536 | Using where |
+----+-------------+----------------+------+---------------------------+-----------+---------+-------+--------+-------------+
1 row in set (0.00 sec)
this is a frequent query we execute, and it would be ideal to optimize this further.

Query Optimization Help Please
I have the following scenario:

* I have n categories
* I have m users
* I have x textlinks

Textlinks are referenced to a category by the ll_partof table.

I am willing to fetch every user (advertiser) for every category and output the date of the last textlink purchased, the number of his textlinks in that category and the amount of money spent in that category.

Here is my query so far. It uses subqueries and is therefore very slow. How can this be optimized? Thanks for any help.

Select
c.name as Kategorie,
(SELECT timestamp
FROM ll_textlink as t
WHERE t.advertiser = u.email
ORDER BY timestamp DESC LIMIT 1
) as last_link,
u.email as Email,
u.forename as Vorname,
u.surname as Nachname,
u.company as Firma,
(SELECT count(id) from ll_textlink as t
WHERE t.advertiser = u.email
GROUP BY t.advertiser
) as num_links,
(SELECT sum(current_value) from ll_textlink as t
WHERE t.advertiser = u.email
GROUP BY t.advertiser
) as budget_links,
FROM ll_user as u
INNER JOIN ll_textlink as t ON (t.advertiser = u.email)
INNER JOIN ll_adspace as a ON (a.id = t.adspace)
INNER JOIN ll_partof as p ON (p.adspace = a.id)
INNER JOIN ll_category as c ON (p.category = c.id)

WHERE
t.extension_possible = &#391;'
AND t.next_period = '-1'
ORDER BY c.id DESC
l

Mysql Optimization
I have table with 7 millions of records , i want to know if some one
can help top optimize the select requests, i created the necessary
indexex but some specific requests still slow.

Query Optimization Help
I've got a query that is trying to find matching rows for two endpoints. Like this...

$sql = "SELECT * FROM my_table WHERE 1234567890 BETWEEN begin_range AND end_range";

The problem is, my_table has about 3.5 million rows, and therefor takes about 4 seconds to run. I've already indexed both the begin_range and end_range fields and I'm just wondering if (other than throwing hardware / memory at the problem) there's anything else I can do?

Is there a better way to query the data?

Optimization Question
I've got a table T with 20 columns (fixed length) and one column C
which is varchar.

Somehow C has to be varchar.

T may have millions of records.

Is there a way to optimize this situation ?

View Optimization
In my database I have separate four tables and from that four tables i have created one view. Each of the table contains round five lacs of records. So when view gives result it is approximately around fifteen lacs of records,

When I call that view like "select * from MyView where name='vimal'" it takes too long to give me result. And due to this one query my application server load increases by 80%. When I execute this view that time mysql Memory consumption is approximately 80% of total memory. What I can do to optimize the same? What are the other alternatives?

Inner Join Optimization
I have Two tables (ENGINE=MyISAM), each table (t1 and T2) have a
primary key bigint (ID),


I execute the request


Select count(*) from t1 inner join t2 on t1.id =t2.id;


it takes 8 secondes


in eahc tables i have more the 2 million records and more. Can anyone
provide me a suggest to resolve this problem (Changing Mysql
parameters , redesign table...?)

Join Optimization
--B_3141046513_16095154
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

I=B9m wondering what (in general) causes a join to use temporary tables and
filesorts...
More specifically, what can I tune to avoid it? I can give more info about
a specific situation if anyone=B9s interested.
All the docs say is that you are likely to get a =B3Using temporary=B2 if you
sort on a different column set than the =B3group by=B2, but I=B9m not doing
that...something else must be triggering it.

WHERE Clause Optimization
if there is a way to optimize 'where' clause with a wild card character, ie - the way star (*) works in unix/linux?
I want to be able to do somsething in this spirit:
WHERE proj != 'P%'
meaning "where data in field proj doesnt start with P"

Join Optimization
what (in general) causes a join to use temporary tables and
filesorts...
More specifically, what can I tune to avoid it? I can give more info about
a specific situation if anyone=B9s interested.

All the docs say is that you are likely to get a =B3Using temporary=B2 if you
sort on a different column set than the =B3group by=B2, but I=B9m not doing
that...something else must be triggering it.

Query Optimization
I am familiar with the VERY basics of MySQL (in other words, I am not an expert...), and I am currently working to create a simple search engine on our website. Users should be able to search a database of over 150,000 sheet music titles by simply inputting a keyword(s) phrase. That phrase should be searched into different tables at the same time but if the keyword phrase includes more than one word, any word need to be searched.

For example, let's say an user is looking for "Brahms violin concerto". The search engine should display all the records that matches all those entered keywords.

Here are the tables that need to be searched:

|title|composer|instruments|description|


and here is the query I am trying to work on (after have split the keyword phrase into separate keywords):

Quote: SELECT title, composer, instruments, description, price FROM mydatabase WHERE (title REGEXP "(^| )brahms( |$)" OR title REGEXP "(^| )violin( |$)" OR title REGEXP "(^| )concerto( |$)") AND (composer REGEXP "(^| )brahms( |$)" OR composer REGEXP "(^| )violin( |$)" OR composer REGEXP "(^| )concerto( |$)") AND ((instruments REGEXP "(^|;| )brahms(;| |$)" OR instruments REGEXP "(^|;| )violin(;| |$)" OR instruments REGEXP "(^|;| )concerto(;| |$)") OR (description REGEXP "(^| )brahms( |$)" OR description REGEXP "(^| )violin( |$)" OR description REGEXP "(^| )concerto( |$)")) order by title like "%brahms%", title like "%violin%", title like "%concerto%", instruments like "%brahms%", instruments like "%violin%", instruments like "%concerto%" The query works, but it takes too long to be executed... over 10 seconds! I am aware that REGEXP (like "LIKE") don't uses indexes, but I cannot find a different solution to match any possible keyword or part of it.

Mysql Optimization
I search through mysql forums but couldn't find a concise place for this topic.

I have a generic table storing a user_ID and some true/false values like 'is_logged_in' etc.

I've discovered that the best way, storage wise, to store those true/false values is through a tinyint(1) with values of 0/1 marking false/true.

I'm wondering what would probably make sense for unique auto incrementing user_ID's. Assume that it may need to get into the millions of users. Any thoughts? Right now I've got it set to int(10) unsigned.

Query Optimization
I have a table, call it 'table1' and a query which looks like:
Code:

SELECT table1.field1, table2.field2 FROM table1, table2 WHERE BINARY table1.username = table2.username AND table2.status = 'Active'

I also have an index set-up on username in table1 and table2. For some reason, mySql does not use the index in table1 for this query, but if I remove the BINARY keyword in the query, the index is used. The type of index is simply 'Index'. Does anyone know why having a case sensetive comparison in the where clause uses index while case-insensetive does not use the index?

Query Optimization
In many of my project. I create an admin welcome page.
On that welcome screen, there is list of all the manageable module names
with their links & the count of number of records under that module.

Example:
Manage Products 104
Manage Customers 235
Manage Orders 430
& so on....


For the count of these records.. I am putting one query for each module..
like "SELECT COUNT(*) FROM products WHERE enumStatus='A'"
For 15 modules, I have to put 15 queries.

EDIT: One module is for one table of the DB

WHERE Statement Optimization
I have a function that tacks together an unknown, variable number of ID numbers that I'm using to filter results in a MySQL. The function constructs a string that looks similar to:

WHERE field = value1 OR field = value2 OR field = value3...

Is there a more optimal way to structure this statment? Can you compare a field against an array, for instance?

Mysql Optimization
just wonder how many columns is the max amount not be an slow table.
Actually I would like to have hundreds of columns, but suppose maybe would be better to have several small, even though that would give me more work updating them.

Query Optimization
This is the query:

$sql = "SELECT DISTINCT(customer_number), upload_date FROM equipment_info WHERE (closed = '0' AND dealer_id ='0') AND ((item NOT LIKE '%Item1%') AND
(item NOT LIKE '%Item2%') AND (item NOT LIKE '%Item3%') AND (item NOT LIKE '%Item4%') AND (item NOT LIKE '%Item5%')
AND item != 'Company Owned Equipment') GROUP BY customer_number ORDER BY upload_date ASC";

yet, I still get this included in the output:

//CI45 Standard Item1 Equip Package, Replacement CI46 LNB Only, Replacement CI33 30 Foot Coax - Yellow

Yet, it was one of the items I wanted it not to match.

MYSQl Optimization
What is Mysql optimization? How I can optimize?

Optimization Advice
I'm having Database connection problem on my VPS server runing SMF forum script.
It often displays "unable to connect to database" notification when there is more than 200 users online (in 15 minute period).
I have raised max mysql connection number from 100 to 150, but that didn't help.
Connections per second number has doubled in last month (but traffic is only slightly higher)

Here are some mysql informations, any advice how to get this numbers to normal values is welcome.

Optimization Of Select
Anybody can help me on optimization some queries
In the slow_query_log the query had the execution time: 12 sec
(Query_time: 12 Lock_time: 0 Rows_sent: 75 Rows_examined: 469546) but if I run the same query in phpMyAdmin i get the time 2,6 seconds.
If I remove the " order by " the query it will be more efficient, but I think there is something wrong if only the ORDER BY it takes like 2 seconds. Any Ideas ?

EXECUTION TIME 2.6183
SELECT cars.id,cars.url,cars.car_name,cars.year, videos.id,videos.brand_id,videos.car_id,videos.name,videos.rewrite FROM cars LEFT JOIN videos ON videos.car_id = cars.id WHERE brandID = '50' ORDER BY year DESC;

EXECUTION TIME 0.0235 sec
SELECT cars.id,cars.url,cars.car_name,cars.year, videos.id,videos.brand_id,videos.car_id,videos.name,videos.rewrite FROM cars LEFT JOIN videos ON videos.car_id = cars.id WHERE brandID = '50' ;

Comparison Optimization
On to my problem. I'm running a query on a table with over 100,000 rows in it. Basically, my query is performing a "similar" check on books that people have logged in their "book list". It looks through the table and checks to see who has the most number of books similar to you. Here's the query:

select count(a.mem_id) as numMatches,m.username,m.mem_id as memberID from book_list a LEFT JOIN book_list_members m ON a.mem_id=m.mem_id where a.book_id in(224,164,30,43,47,1,6,52,90,45,120,270,...,2442) GROUP BY a.mem_id ORDER BY numMatches DESC LIMIT 50

In the in() comparison, this can be anywhere from 1 integer to 1000 integers, it all depends on how many books a user has in their list. I've indexed "book_id", but unfortunately if there are more than say, 100 elements in the IN() comparison, the query takes anywhere from 1-2 seconds to execute. That's a long time when I have hundreds of users hitting a website and running that query. Is there a better way to do this? Is there a way I can "store" this query result somewhere, and only have it updated every couple hours (cached in other words, for immediate access).

SELECT Optimization
I have a table that basically keeps track of the ID numbers of items in 9 other tables.
I do have the need to see all the 'real' information at once and not just the ID numbers.
So, my question is. Is it better to have a SELECT statement with 9 JOINs in it, or to have the SELECT statment only pull the ID numbers and then do separate SELECTs on each ID number.The logic of my brain suggests the first, but I just wanted to check.

Sub Query Optimization
I am running a dated version of mysql, like 3.23.xx, and I have a query:
Code:


$sql = "SELECT * FROM users_info
WHERE first_name != '' AND users_id IN (SELECT DISTINCT id AS list FROM equipment WHERE id != '0' GROUP BY list )
ORDER BY last_name ASC ";


The query is substantial slower than just running a nested query

MySQL Optimization & Ignored Indexes:
I'm a little confused as to why the following indexes would be ignored? Can someone shed a little light on this?

Simple order by: ........

Mysql Index Optimization
Can anyone suggest which index is optimal for table "items"?
CREATE TABLE categories (
id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id TINYINT(2) UNSIGNED NOT DEFAULT 0,
name VARCHAR(30) NOT NULL DEFAULT '',
count MEDIUMINT(8) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
INDEX parent_id (parent_id)
);
CREATE table items (
id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
cat TINYINT(2) UNSIGNED NOT DEFAULT 0,
sub_cat TINYINT(2) UNSIGNED NOT DEFAULT 0,
sub_cat_sub TINYINT(2) UNSIGNED NOT DEFAULT 0,

PRIMARY KEY (id),
/* option 1 */
INDEX browse (cat, sub_cat, sub_cat_sub, pageviews)
/* option 2 */
INDEX sub_cat_sub (sub_cat_sub, pageviews),
INDEX sub_cat (sub_cat, pageviews),
INDEX cat (cat, pageviews),
);

Note that the results in "sub_cat" is a subset of the results in "cat" as is "sub_cat_sub" to "sub_cat", so that "sub_cat_sub" is most unique. The user must be able to browse all items found in a specified category (cat), the items found in the subcategory of that category (sub_cat), and the subcategory of that subcategory (sub_cat_sub).

I am aware option 1 will make INSERT faster and will save disk space compared to option 2. However, the option 2 will make SELECT faster and save memory usage as the index used is optimal (in terms of from most unique to least unique). Also with option 1, the only time an index is used to sort (by pageviews) is when all three categories are set.



Mysql Optimization Tool
Is there any tools that you can just run on your server that will automatically optimize your mysql database? Like to speed it up,clean it etc.

Query Optimization Advice?
I am familiar with the VERY basics of MySQL (in other words, I am not an expert...), and I am currently working to create a simple search engine on our website. Users should be able to search a database of over 150,000 sheet music titles by simply inputting a keyword(s) phrase. That phrase should be searched into different tables at the same time but if the keyword phrase includes more than one word, any word need to be searched.

For example, let's say an user is looking for "Brahms violin concerto". The search engine should display all the records that matches all those entered keywords.

Here are the tables that need to be searched:

|title|composer|instruments|description|


and here is the query I am trying to work on (after have split the keyword phrase into separate keywords):

Quote:

SELECT title, composer, instruments, description, price FROM mydatabase WHERE (title REGEXP "(^| )brahms( |$)" OR title REGEXP "(^| )violin( |$)" OR title REGEXP "(^| )concerto( |$)") AND (composer REGEXP "(^| )brahms( |$)" OR composer REGEXP "(^| )violin( |$)" OR composer REGEXP "(^| )concerto( |$)") AND ((instruments REGEXP "(^|;| )brahms(;| |$)" OR instruments REGEXP "(^|;| )violin(;| |$)" OR instruments REGEXP "(^|;| )concerto(;| |$)") OR (description REGEXP "(^| )brahms( |$)" OR description REGEXP "(^| )violin( |$)" OR description REGEXP "(^| )concerto( |$)")) order by title like "%brahms%", title like "%violin%", title like "%concerto%", instruments like "%brahms%", instruments like "%violin%", instruments like "%concerto%"

The query works, but it takes too long to be executed... over 10 seconds! I am aware that REGEXP (like "LIKE") don't uses indexes, but I cannot find a different solution to match any possible keyword or part of it.

Any suggestion to optimize it? Or should I work on a completely different approach?

Mysql 5.1 My.conf Optimization
Can someone help me about my.conf ?

I'm using a mysql dedicated server like this :

Intel Xeon
2,66 GHz / 2,67 GHz
Windows 2003 SP1
Memory 4 GB of RAM
Mysql 5.1

Can you tell me for my.conf parameters the max and min values recommended ? (for example by posting a my.conf with comments in each parameter telling max and min values to use).

For informations in the soft using DB:

- A lot of user
- A lot of datas in some big tables (not a lot of join in queries)
- Some data sorts or order returning a lot of data

Small Query Optimization
I need this query optimized using indexes. So I was wondering how I could optimize it to work with an index for speed.The query is:

Quote: select ided from products where dates <= 2006-11-11 or cost=0.00 or url not like 'http://%' or imgurl not like 'http%'

I tried making an index on (dates,cost,url,imgurl) but it doesn't seem to use the index when I do the explain part. I find that even when I miss of the like parts of the query it still is not using the index. It seems to not use the index because of the "or" that is used in the query instead of the "and". Could this be the reason and how could I over come this so that it will use the index.

Slow Queries And Optimization
I am hosting a site with an increasing number of members. Letely the site has become slower because of too many queries are being used.
Is there a way of asking the server which queries are used most often, as well as asking which queries take a long time to process so that I would know where to start my optimization process?

Search Table Structure Optimization
I am trying to design a database for a search engine so that the structure of my tables is fitting for a high density of queries/hour.

Originally, my 'search database' was a single table, with joins from other tables f necessary. I then used mysql 'like' to fetch data for search. No caching, so very rudimentary, I know. (Don't worry about having to port data over. I'm starting over with a brand new project knowing this isn't the best solution, and trying one you propose!)

I would like to know how I should set up the tables and columns I should add to enable caching. Or, any other solutions to the problem of designing a database for efficient search!

Examples of existing search engine database structures would also be appreciated. How is Google's database designed?

MySQL Expert, Optimization Queries
Need someone to optimize my database.

I have dedicated server for mysql, which is always overloaded. I run there DB for site with 120k-150k uniques/day.

Something is wrong there. Please PM me if u are interested in that kind of job and you have sufficient skills. need it asap

Help With A Small Query Optimization Using An Index. THANKS!
I need this query optimized using indexes. So I was wondering how I could optimize it to work with an index for speed.

The query is:

Quote:

select ided from products where dates <= 2006-11-11 or cost=0.00 or url not like 'http://%' or imgurl not like 'http%'

I tried making an index on (dates,cost,url,imgurl) but it doesn't seem to use the index when I do the explain part. I find that even when I miss of the like parts of the query it still is not using the index. It seems to not use the index because of the "or" that is used in the query instead of the "and". Could this be the reason and how could I over come this so that it will use the index.

Database Optimization Width MySQL ?
Object : How to optimize mysql architecture for better web connection
?

Hello, I use phpMyAdmin 2.3.2 and MySQL 3.23.58 and I do not know how
to well-organize mysql architecture for the user convience and
speedness.

On my web site, I call all the stucture from one table (5 colums and
50 rows).

Today, 600.000 connections per day are made to this table.

Each time, the queries using PHP do selections (example> SELECT * FROM
table_website WHERE CODE like 'RLINK%'.

The problems comes more and more often : like
1. mysql_connect(): Host 'localhost.localdomain' is blocked because
of many connection errors.
2. or like the query is very slow.

and I have to reboot the linux server each week to try to avoid these
problems.

We would like to have more people coming and to increase the numbers
to 1 or 1.2M connections per day.

My questions would be :
1. On a architecture point of vue, is it better to have only One table
or to have multi-tables.
2. I read http://www.mysql.com/documentation/...timisation.html
but I could not find advises concerning many connections to one single
table.

I did not changed any general variable provided in standard width
mysql.

From what you think, What kind of possible implementation or change in
architecture I could make ?

Here, is the tipical query I make to select items within the table :

<?php
srand ((double) microtime() * 948625);
include "/config/config.php";
$idCnx = mysql_connect($host ,$user,$pass ) or die("Impossible de se
connecter à la base de données");
mysql_select_db($bdd) or die("Impossible de se connecter à la base de
données")..............................................

Cross Join Effects With Query Optimization
ELECT count(t.id)
FROM `ll_textlink` AS t, `ll_period` AS p , `ll_user` AS ua , `ll_user` AS up
WHERE
t.actual_period = p.id
AND p.status_approval_publisher = &#391;'
AND p.value > &#390;'
AND t.online >= &#395;'
AND &#391;' >= (
SELECT count(p.id)
FROM `ll_period` AS p
WHERE p.textlink = t.id
)
AND t.online <> &#394;'
AND t.current_value > &#390;'
AND t.advertiser = ua.email
AND t.publisher = up.email
AND ua.rights = &#390;'
AND up.rights = &#390;' ;
This is what I am at now:



SELECT count(t.id)
FROM `ll_textlink` AS t
INNER JOIN `ll_period` AS p ON (p.textlink = t.id)
INNER JOIN `ll_user` AS ua ON (ua.email = t.advertiser)
INNER JOIN `ll_user` AS up ON (up.email = t.publisher)
WHERE
t.actual_period = p.id
AND p.status_approval_publisher = &#391;'
AND p.value > &#390;'
AND t.online >= &#395;'
AND t.online <> &#394;'
AND t.current_value > &#390;'
AND ua.rights = &#390;'
AND up.rights = &#390;' ;
However, the number return is quite a bit higher than the from the first query. Are there any cross-join effects and if so how can I avoid them?


Copyright © 2005-08 www.BigResource.com, All rights reserved