Most efficient way of handling a large dataset

2008-10-24 Thread Mark Goodge
I'd appreciate some advice on how best to handle a biggish dataset consisting of around 5 million lines. At the moment, I have a single table consisting of four fields and one primary key: partcode varchar(20) region varchar(10) location varchar(50) qty int(11) PRIMARY KEY (partcode, region, lo

Re: Most efficient way of handling a large dataset

2008-10-24 Thread Jim Lyons
You might consider adding qty to the index and have so your queries would be satisfied with the index lookup alone, saving an extra step since the database won't then go access the data (just the one field, qty). You might also consider making all field non-null and, if you keep the fields as char

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
SELECT ProductName FROM Products WHERE ProductScore > 100 ORDER BY CASE WHEN ProductScore = 125 THEN 0 ELSE 1 END, ProductScore But this query won't use an index, so it would be a good idea to do this in two queries 2008/10/24 Tompkins Neil <[EMAIL PROTECTED]> > Hi > > I've the following

ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi I've the following basic query like SELECT ProductName FROM Products WHERE ProductScore > 100 ORDER BY ProductScore However, how can I order by ProductScore, but ensure the product with ID 125 is at the top ? Is this possible. Thanks Neil

Re: Most efficient way of handling a large dataset

2008-10-24 Thread Brent Baisley
On Fri, Oct 24, 2008 at 6:59 AM, Mark Goodge <[EMAIL PROTECTED]> wrote: > I'd appreciate some advice on how best to handle a biggish dataset > consisting of around 5 million lines. At the moment, I have a single table > consisting of four fields and one primary key: > > partcode varchar(20) > regio

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
Following on from my email below I now need help with the following problem. Here is a list of my sample data Date ProductID ProductNameProductScore Quantity 2008-11-10100 Red Light 0.05 10 2008-11-11100

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
SELECT ProductID, ProductName, AVG(ProductScore * Quantity) AS a FROM Products GROUP BY ProductID ORDER BY a DESC 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: > > Following on from my email below I now need help with the following > problem. Here is a list of my sample data > > Date

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi This works, however I still want to be able to list the whole list like because I need to display it on the screen, but in the ordered together i.e all RedLights, all BlueLights etc a Date ProductID ProductName ProductScore Quantity %2008-11-

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
Could give us sample values for "a" field? Should it contain the same thing as in the query I've sent? 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: > > Hi > > This works, however I still want to be able to list the whole list like > because I need to display it on the screen, but in the ordered

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi Thanks for your quick reply. The sample value for "a" would be like a average of integer. e.g 6.01, or 10.19. Neil On Fri, Oct 24, 2008 at 2:49 PM, Olexandr Melnyk <[EMAIL PROTECTED]> wrote: > Could give us sample values for "a" field? Should it contain the same thing > as in the query I've

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
Still doesn't make much sense to me. Could you show us how to calculate it for some of the rows above? 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: > > Hi > > Thanks for your quick reply. The sample value for "a" would be like a > average of integer. e.g 6.01, or 10.19. > > Neil > > On Fri, Oct

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi Basically from the query below, it would only return one product like RedLight. But I need to return a list of all products, ordered by a SELECT ProductID, ProductName, AVG(ProductScore * Quantity) AS a FROM Products GROUP BY ProductID ORDER BY a DESC On Fri, Oct 24, 2008 at 2:53 PM, Ol

Re: Stopping DNS Lookups

2008-10-24 Thread Richard S. Huntrods
Yes, that's exactly what the link from Hassan said to do. Interestingly, what is not stated in that link is that you must add entries in mysql tables 'db' and 'user' for '127.0.0.1' (a.k.a. 'localhost') if you need to access the database from the local server. Remote access via static IP (assu

Re: which solution is better for $count and @cols

2008-10-24 Thread Perrin Harkins
On Thu, Oct 23, 2008 at 10:31 PM, Fayland Lam <[EMAIL PROTECTED]> wrote: > B one SQLs with some operation > SELECT col FROM table WHERE $where > while $count is scalar @cols and real cols is splice(@cols, $start, $rows) If you're talking about Perl/DBI, doing that normally loads the entire result

Re: Stopping DNS Lookups

2008-10-24 Thread Richard S. Huntrods
Not on my testing system (Win-XP). I test on Win-XP but deploy on Unix. Not only that, but the production application servers are separate from the database server, so I never use localhost in production anyway. But on the XP test server, I had to add the 127.0.0.1 entries to 'db' and 'user' -

Re: Most efficient way of handling a large dataset

2008-10-24 Thread Joerg Bruehe
Hi Mark, all! Mark Goodge wrote: > I'd appreciate some advice on how best to handle a biggish dataset > consisting of around 5 million lines. At the moment, I have a single > table consisting of four fields and one primary key: > > partcode varchar(20) > region varchar(10) > location varchar(50)

auto_increment problem

2008-10-24 Thread Paul
Anybody know if there's a way to change a primary key field that is not auto-incremented, turning on auto-increment but preserving the values that are currently in it? TIA, Paul W -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysq

How to count # of character occurrences in a string?

2008-10-24 Thread mos
I have a Char column with text data like "ab:cdef:h" and I'd like to count the number of ":" in the column. I can't find an easy way to do it. I thought there should be a MySQL function to do this. Any suggestions? TIA Mike -- MySQL General Mailing List For list archives: http://lists.mysql.c

Re: How to count # of character occurrences in a string?

2008-10-24 Thread Pintér Tibor
I have a Char column with text data like "ab:cdef:h" and I'd like to count the number of ":" in the column. I can't find an easy way to do it. I thought there should be a MySQL function to do this. Any suggestions? select length('aa:bb:cc:dd')-length(replace('aa:bb:cc:dd',':','')); btw ever

Re: How to count # of character occurrences in a string?

2008-10-24 Thread Jim Lyons
A quick and dirty way would be to use an expression like length(x) - length(replace(x, ":", "")) Here's some code that I actually ran: set @x = "aa:bb:cc:dd"; set @colons = length(@x) - length(replace(@x, ":", "")); select @x , @colons; On Fri, Oct 24, 2008 at 5:16 PM, mos <[EMAIL PROTECTED]

Re: mysqld, mysqld-nt, mysqld-debug

2008-10-24 Thread Moon's Father
Hi. I think you had a mistake for the server types.Mysql-nt.exe is the only exexutable program on windows.So you just pay close attention about it. On Mon, Oct 6, 2008 at 8:35 PM, Steven <[EMAIL PROTECTED]> wrote: > > Steve > (n) > Martin! > > > > if you want apache and mysql (and possibly PHP

Re: mysqldump: Error 5: Out of memory

2008-10-24 Thread Moon's Father
Show the details of your hardware us. On Thu, Oct 2, 2008 at 3:02 PM, Krishna Chandra Prajapati < [EMAIL PROTECTED]> wrote: > Hi, > > Just try the below command on console. It will give that the error is > exactly related to what. > > $perror 5 > > What is total ram in your box. > > > On Thu, Oct

Re: Speed up slow SQL statement.

2008-10-24 Thread Moon's Father
You may see the section named group by optimization on the document. On Tue, Sep 30, 2008 at 4:44 AM, Rob Wultsch <[EMAIL PROTECTED]> wrote: > Glancing over things I suggest: > ALTER TABLE browse_nodes_to_products ADD INDEX(browse_node_id,product_id); > > (if product_id has greater cardinality pu

Re: MySQL 5.1 Function Creation

2008-10-24 Thread Moon's Father
Make sure your log_bin_trust_function_creator is on. On Sun, Sep 28, 2008 at 3:04 AM, Jesse <[EMAIL PROTECTED]> wrote: > I'm trying to use existing functions from a restored database from 5.0xx to > 5.1, and get an error about the mysql.proc table is missing or corrupt. The > mysql.proc table app

Re: How could i check the following values in MySQL Server 5.0

2008-10-24 Thread Moon's Father
Any additional tools will satisfy your demand. On Mon, Oct 13, 2008 at 7:34 PM, Sudhir Menon <[EMAIL PROTECTED]> wrote: > My reply was with regards to the answer in this post. > http://lists.mysql.com/mysql/214827 > > Anyways thanks for the concern from your end.. Mike :) My query was > answered

Re: order of items in a WHERE...IN clause

2008-10-24 Thread Moon's Father
See the usage of the function named field. On Mon, Jul 28, 2008 at 8:15 PM, Mr. Shawn H. Corey <[EMAIL PROTECTED]>wrote: > On Mon, 2008-07-28 at 07:32 -0400, Gary Josack wrote: > > Andrew Martin wrote: > > > Hello, > > > > > > Is it permissible to order a clause such that the search term is the >

Re: MYSQL DB BACKUP

2008-10-24 Thread Moon's Father
There are some of backup scripts written by me.You can find it at: http://blog.chinaunix.net/u/29134/article_71953.html On Wed, Oct 22, 2008 at 4:52 PM, Mad Unix <[EMAIL PROTECTED]> wrote: > Any one tried the script from HowToForge > > > http://www.howtoforge.com/shell-script-to-back-up-all-mysql

Re: Tables are too wide

2008-10-24 Thread Moon's Father
Just use another term will solve your problem.Or you can use pager more in mysql command line client. On Sun, Sep 28, 2008 at 12:44 AM, Dan Nelson <[EMAIL PROTECTED]>wrote: > In the last episode (Sep 27), Alex Katebi said: > > Hi, > > > > When selecting (example: select * from mysql.db ) some o

Re: Finding gaps

2008-10-24 Thread Moon's Father
Create an extra trigger on that table with delete event.Then the deleted item will be recorded in the database. On Fri, Oct 10, 2008 at 11:34 PM, Jerry Schwartz <[EMAIL PROTECTED] > wrote: > Thanks. > > > > Although I've been around SQL for quite a while, I've never really gotten > the hang of se