473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to optimize this slow join?

43
hi everyone , i am trying to join two tables , the query is working fine when the records in the tables are less but when the records are in huge numbers say 1-2 million then the system hangs... i am using version 4.1 and the query is

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(dummy.username)AS count
  2. FROM dummy2 
  3. LEFT JOIN dummy ON dummy2.msg_id = dummy.msg_id
  4. where dummy2.username like 'xyz' 
  5. GROUP BY dummy2.username
plz give any suggestions to optimize this so that it works for large records also..
Oct 26 '07 #1
2 1951
amitpatel66
2,367 Expert 2GB
hi everyone , i am trying to join two tables , the query is working fine when the records in the tables are less but when the records are in huge numbers say 1-2 million then the system hangs... i am using version 4.1 and the query is

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(dummy.username)AS count
  2. FROM dummy2 
  3. LEFT JOIN dummy ON dummy2.msg_id = dummy.msg_id
  4. where dummy2.username like 'xyz' 
  5. GROUP BY dummy2.username
plz give any suggestions to optimize this so that it works for large records also..
Use an = operator insted of LIKE.

Eg:

dummy2.username = 'xyz'

This will improve the performance for sure
Oct 26 '07 #2
pbmods
5,821 Expert 4TB
Heya, Bravo.

Changed thread title to better describe the problem (threads whose titles do not follow the Posting Guidelines actually get fewer responses).

What happens when you EXPLAIN the query?
Oct 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mjuricek | last post by:
I'm having some problems to optimize my stored procedure (select statement with joins) What I'm trying to do is calculate total work. My situation: I have 3 tables I'm using -Input (char...
1
by: malcolm | last post by:
This one's kind of hard to explain, so I've opted to post a simplified version of our view that prompted me to ask this question: The question is re-asked after the view... create view MainView...
12
by: Neil | last post by:
I previously posted re. this, but thought I'd try again with a summary of facts. I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that is linked to the database via ODBC...
2
by: Yonatan Goraly | last post by:
I am in the process of adding PostgreSQL support for an application, in addition to Oracle and MS SQL. I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board. I have a...
0
by: Michal Hlavac | last post by:
Hello, I have one main table and 2 many-to-many relation tables and 2 one-to-many relation table. Main table has 150 000 rows and many-to-many tables have about 300 000 rows. I am creating...
4
by: Huaer.XC | last post by:
>From the following MySQL command: EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON t3.name = t1.name WHERE t1.id IN(123, 124); which result is:...
19
by: octangle | last post by:
This code is attempting to find records that have a RegJrnID that does not occur more than one time in the table. The reason that I want to find records with non-duplicated RegJrnID values is to...
2
by: bsagert | last post by:
I wrote my own feed reader using feedparser.py but it takes about 14 seconds to process 7 feeds (on a windows box), which seems slow on my DSL line. Does anyone see how I can optimize the script...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.