Puddleboy posted:So for each user, there are multiple articles? Ah, that is what I needed. So what about the performance issue? It takes ~4s to run this query.
|
|
# ¿ Mar 21, 2008 02:38 |
|
|
# ¿ May 14, 2024 04:37 |
minato posted:Make sure you have an index on both article.owner and user.id. user.id is the primary key for the user table For the article table I have article.id as the primary. There are also separate indexes for article.owner, article.pictureId, and article.hits. When I do an EXPLAIN for the slow query, I see this: possible_keys: owner key: null ref: null rows: 315615 (which is the size of that table) Extra: Using where; Using temporary; Using filesort edit: Side question, but how do I chose my CHARSET and COLLATE for a table? fletcher fucked around with this message at 07:47 on Mar 21, 2008 |
|
# ¿ Mar 21, 2008 07:18 |
Anybody have any ideas about my indexing/performance issue a few posts up? Or about CHARSET and COLLATE?
|
|
# ¿ Mar 25, 2008 19:09 |
If I'm trying to optimize a query that has joins on it, am I supposed to (multicolumn)index the fields I'm joining on? Or just the fields in the WHERE? What about the field I'm doing an order by on?
|
|
# ¿ Apr 3, 2008 01:55 |
minato posted:<wisdom> So will I end up having columns that are indexed multiple times depending on how I'm looking up the data? Like: indexA: (first_name, last_name) indexB: (birthday, last_name)
|
|
# ¿ Apr 3, 2008 03:45 |
If you have a users table and an articles table, what do you guys name the column that links the article to the user? 'userId' or something more descriptive like 'authorId'? edit: I guess I should note this is for MySQL/MyISAM table, if that makes any difference. fletcher fucked around with this message at 06:23 on Apr 8, 2008 |
|
# ¿ Apr 8, 2008 06:13 |
I wanna add the ability to search my site and I'm wondering if I should even bother with MySQL's fulltext after hearing so many bad things about it. What are some alternatives I should look at that I can use with PHP?
|
|
# ¿ Apr 9, 2008 05:28 |
Why does adding an index on one columnn speed up one SELECT query a lot while it slows down another SELECT query? Or should that not happen and something else is causing it?
fletcher fucked around with this message at 07:28 on Apr 15, 2008 |
|
# ¿ Apr 15, 2008 07:25 |
genericadmin posted:Many databases allow for index hints of some kind. MySQL has "USE/IGNORE/FORCE INDEX"....I've had lots of instances with MySQL where hints were a must. I was just about to ask about this. It seems like a strange thing to need to specify. How do I know if it is a situation where I have to specify the index to use?
|
|
# ¿ Apr 15, 2008 20:10 |
I'd like to log the slow queries in separate files for each website on the server. I see that you can specify a user config file in ~/.my.cnf. Is that supposed to be the username of the user you are logging into the DB with? I have no clue how to set this up.
|
|
# ¿ Apr 15, 2008 21:32 |
Is there a way to use mysqldump to dump a database and stuff it into a different one in a single command?
|
|
# ¿ Apr 30, 2008 18:48 |
fansipans posted:Since mysqldump just outputs SQL you can do this on the command line: Hah! Good stuff, thanks. Is there a way for it to hesitate to let me put in passwords when I do something like: code:
Enter password: Enter password:
|
|
# ¿ Apr 30, 2008 19:32 |
What's the most efficient way to query a table for timestamps that are < 15 minutes old in MySQL?code:
code:
|
|
# ¿ Jul 15, 2008 23:27 |
Is there any way to keep mysqldump from killing server performance while it's running? edit: It seems it is because it locks the tables. Can I do a live replication on the same machine? fletcher fucked around with this message at 02:02 on Jul 31, 2008 |
|
# ¿ Jul 31, 2008 01:53 |
In MySQL, when you delete a row from a table it creates 'overhead', which from my understanding is the row still exists, it's just marked as deleted. To clear the overhead, I can do an OPTIMIZE TABLE. Is this supposed to just be done on a weekly basis with a cron job or what?
|
|
# ¿ Aug 7, 2008 10:01 |
If there are two tables (mysql): product -id name productvote -productId -timestamp I'm trying to get a list of products ordered by the time it was last voted on. SELECT product.id, product.name FROM productvote JOIN product ON product.id = productvote.productId ORDER BY productvote.timestamp DESC; That seemed to work, but it can show duplicate products. Doing a SELECT DISTINCT instead didn't seem to work like I thought it did, why not? Or should I do it like this? How do I maintain the order of the productIds inside the IN() in the result of the parent query? SELECT product.id, product.name FROM product WHERE product.id IN (SELECT DISTINCT productvote.productId FROM productvote ORDER BY productvote.timestamp DESC);
|
|
# ¿ Dec 17, 2008 20:41 |
Thanks for all the responses guys.Jethro posted:given that it's mysql, you probably want something like This query seems really slow (~2 sec for a pretty small data set) What indexes would help me with a query like this? code:
|
|
# ¿ Dec 18, 2008 03:46 |
Yep, there is. edit: ^ yeah that's why I asked, I don't know how to make sense of it either. fletcher fucked around with this message at 04:44 on Dec 18, 2008 |
|
# ¿ Dec 18, 2008 04:28 |
How do you decide when it's appropriate to use a trigger vs. doing it from the application code?
|
|
# ¿ Jan 2, 2009 07:58 |
I'm using MySQL and I was wondering if there is an easy way to do the following: SELECT Product, SUM(B1) as group0, SUM(B2) as group1 FROM table WHERE Product IN ('a', 'b', 'c') GROUP BY Product Now let's say there's also a Product 'd' which is defined as a family of products: the sum of 'a' and 'b' = 'd'. Is there a way to have MySQL calculate 'd' for me as well? I'm currently just doing it in java after the above query executes. Note that the product family is not defined in a MySQL table (retarded, yes). fletcher fucked around with this message at 02:30 on Jan 24, 2009 |
|
# ¿ Jan 24, 2009 01:55 |
camels posted:something like this? Yes! How come the portion after UNION won't properly GROUP BY the Product though?
|
|
# ¿ Jan 31, 2009 02:13 |
camels posted:The result set in effect only has one Product, so the SUM() acts on the whole result set, and doesn't need a GROUP BY statement, if that makes sense. Oh I was trying to be lazy and reuse most of the SQL statement already built since it's huge. I don't know why I didn't realize that. I need some sleep I think. Thanks!
|
|
# ¿ Jan 31, 2009 04:19 |
How can you speed up a query such as the following? (MySQL)code:
|
|
# ¿ Mar 20, 2009 08:42 |
Why doescode:
code:
This is on MySQL 5.1, running on Windows.
|
|
# ¿ Aug 20, 2009 03:39 |
I want to add the ability for users to specify a timezone so I can display timestamps with the appropriate offset in a MySQL based application. Is using set timezone = timezone a bad idea? Should I be doing this in my application code, rather than just setting it at the database level? edit: actually, I'm not even sure that it's even necessary to display exact timestamps in this app. I think X hours/days/weeks/months/years ago is all people will need. Still curious about where in an application timezone conversion should be done though. fletcher fucked around with this message at 23:52 on Sep 22, 2009 |
|
# ¿ Sep 22, 2009 23:48 |
MySQL question here: Let's say I've got a table with 52 columns, named COLUMN1, COLUMN2, etc. Each row of this table has data for each column, but for some rows COLUMN1 could correspond to 12/1/2009 and for other rows COLUMN1 could correspond to 10/15/2009. For each row, the amount of time between COLUMN1 and COLUMN2 could be 1 week or 1 month. First of all, is this type of thing commonly done? Does it have a name where I can read about working with data like this? I'm trying to do things like viewing weekly data at a monthly or quarterly scale, and I'm running into all kinds of weird situations and need some direction on this.
|
|
# ¿ Oct 28, 2009 23:43 |
Markoff Chaney posted:What Sprawl said. So your rows look like DATE1, DATE2 (which is later than DATE1), DATA_1, DATA_2, DATA_N? Or is this something more sinister and insane? Kinda. Each row has a date assigned to the first DATA_1 column, and a scale (weekly or monthly) that indicates how far away DATA_2 is from it. Scaramouche posted:How many rows are involved? Is each column time stamped, or does column2-column=1 week | 1 month occur randomly? 100s of millions
|
|
# ¿ Oct 29, 2009 16:17 |
Sprawl posted:This sounds like it was bad data planning from the beginning. I would refactor the whole thing hth. No, one date and one scale for each row.
|
|
# ¿ Oct 29, 2009 17:08 |
Jethro posted:What on earth does "Each row has a date assigned to the first DATA_1 column" mean? When you say assigned, that sounds like it means DATA_1 is where that date is stored. But from the context of your explanation, I think you mean that DATA_1 has actual data, and the "start date" and scale (and presumably other identifying information) are stored in other columns in the row that you didn't mention. Ya! That sounds exactly right.
|
|
# ¿ Oct 29, 2009 17:31 |
badatshess4ever posted:I apologize if this has been asked in some form, I read through a few pages but can't go through all 71. I took a database class in college and have some experience with querying, but none actually building databases.. Nice troll
|
|
# ¿ Nov 4, 2009 01:58 |
What is the correct way to do what I am trying to do? This obviously won't work, since I can only have 1 field in the subquery: code:
code:
|
|
# ¿ Nov 19, 2009 01:19 |
camels posted:Something like this (untested)? Worked great! Thanks!
|
|
# ¿ Nov 19, 2009 19:29 |
I have a VARCHAR(1300) column that I want to sort my results by. There wasn't an index on it so it was pretty slow, but when I try to add an index to it I get: "Specified key was too long; max key length is 1000 bytes" Is there another way to get the query to run faster?
|
|
# ¿ Nov 19, 2009 23:12 |
Sprawl posted:use a fulltext index? or convert it to a text field and put a fulltext index on it? I tried using a fulltext index, but it was still slow, and EXPLAIN said it wasn't using an index. I also tried specifying with USE INDEX() and it was still slow. Same results whether it's a VARCHAR or TEXT field.
|
|
# ¿ Nov 19, 2009 23:32 |
Using MySQL, I'm creating a temp table:code:
Unfortunately, I don't have enough memory on this machine to have temp tables in memory that are that big for X number of users. Are there other ways I can speed this up? 2 minutes to load 50,000 rows seems like way too long. edit: specifying ENGINE = MyISAM, overriding the InnoDB default, yields a 10 second load time. Hurrah! fletcher fucked around with this message at 00:04 on Dec 3, 2009 |
|
# ¿ Dec 2, 2009 23:04 |
Triple Tech posted:Take off the index. If you want to speed up writes, drop all indices. Then if you need the index for reporting purposes, recreate it. Interesting...so it would be faster to not have the indicies in the CREATE, and to just create them one I'm done inserting? Sprawl posted:i can't even imagine why you would put a 1300 character field into the primary key that doesn't make any sense. Whoops, that should really be SomeOtherField, not the long one.
|
|
# ¿ Dec 3, 2009 00:02 |
Comatoast posted:So, how do I go about creating a table which can hold an infinite number of authors? Sorry, but that is a really dumb question. Go buy an infinite number of hard drives? What class is this for?
|
|
# ¿ Dec 10, 2009 00:15 |
Comatoast posted:Bah. You're right. I'm just going to say 100 is the max and go from there. I know how to do that. You don't need to say infinite or even 100, just say "arbitrary number of authors" or something. You need three tables, publication, author, and a table to relate the two to each other. If this whole class was about databases and you can't do this by the end of the semester...well...start putting effort into school and stop wasting your parents money?
|
|
# ¿ Dec 10, 2009 00:31 |
Sprawl posted:This is really easy and i shouldn't give it to you but you sound a little slow, think second normal. Boooooooo! You should have let him figure this poo poo out.
|
|
# ¿ Dec 10, 2009 00:48 |
|
|
# ¿ May 14, 2024 04:37 |
I needed to remove a trailing space from a certain column and I tried to use this query to find out which rows I would be updating:code:
|
|
# ¿ Jan 18, 2010 19:46 |