Forum Moderators: open
I have my main table with about 20 fields and i select like 15 of them and display 50 per page.
It was very fast ( < 1sec )when i had little over 1000 records, then i added about 300 000 to see the speed and it was very slow about 12 seconds to display 50 rows but of course it went through all of the records to get its count, so i can calculate the LIMIT.
i have VDS (Redhat 9) with
512 Bandwidth
256 Ram
and here is mysql configuration:
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 32M
max_allowed_packet = 1M
table_cache = 2000
sort_buffer_size = 1024K
net_buffer_length = 16K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
I have indexes in the right place and so but the thing is that what if i want to just read all the rows? Shouldnt be a way to make it faster?
Should i uppgrade the RAM to 512? and what would be the optimal MySQL configration setting?
Thanks in advance
you're joining three tables together, ordering and using a set to match against for TYPE
my gut says this query will be slow anyway, though you may be able to speed it up with indexes etc
maybe take a look at the option of splitting this single query into multiple queries and benchmarking
I did some testing and found out that same query would execute in about 0.15 Sec instead of over 9 Sec just by removing:
ORDER BY datetime DESC
So have you any fast alternative so the table get sorted by datetime without having to use the "order by"?
Thanks in advance
My current configurations:
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16M
join_buffer = 1M
max_allowed_packet = 16M
max_connections=300
wait_timeout=100
connect_timeout=10
table_cache = 1024
sort_buffer_size = 10M
net_buffer_length = 16K
read_buffer_size = 10M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 64M
query-cache-type = 1
query-cache-size = 32M
query_cache_limit = 1M
I want it to be very fast in sorting but without destroying other options...
Thanks in advance
as much as normalizing data is great, some data redundancy can often speed up the system by leaps and bounds
as far as an alternative to sort, well i don't know one off the top of my head
you could look at the speed of sorting using your scripting language, might work, I have a sneaking suspicion though that reading all those rows into an array and sorting, then chopping out what you don't want will be slower, or at least equally slow.
Queries involving 300k records really demand a fairly hefty processor and at least 1GB ram for sub-second execution, or you are likely to get disk swapping which will kill performance.
[edited by: FalseDawn at 8:29 pm (utc) on Jan. 7, 2007]
Just a technical question, if there is slow query that takes for example 10 seconds on 256 RAM, it could be optimized and everything to go down for example to 1 second, but lets say it wasnt optimized and the RAM was upgraded to 4 Giga how many seconds would that query run through?
Thanks
If you are not swapping, you will need a faster processor to speed your queries up, all other things being equal.
Looking at your MySQL "runtime information" (phpMyAdmin) should help locate any issues.