Re: Rewrite SQL to stop table scan

2011-01-17 Thread Steve Meyers
On 1/17/11 9:52 AM, Jerry Schwartz wrote: [JS] I don't understand how an index on a timestamp would help. Theoretically, each record could have a unique value for the timestamp; so the index would have an entry for each record. Would MySQL really use that in preference to, or in combination with,

RE: Rewrite SQL to stop table scan

2011-01-17 Thread Jerry Schwartz
>> >> SELECT COUNT(*) AS num FROM alerts WHERE stamp > DATE_SUB(NOW(), >> interval 300 second) AND devid=244; >> >> With this query, MySQL will run DATE_SUB() once, and then use the >> index on stamp (which I assume you have) to narrow down the result set. >> [JS] I don't understand how an index o

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Bruce Ferrell
On 01/14/2011 08:19 AM, Steve Meyers wrote: > On 1/14/11 3:52 AM, Bruce Ferrell wrote: >> select count(*) as count >> from alerts where (unix_timestamp(stamp)> (unix_timestamp(now()) - >> '300' ) ) >> and devid = '244'; >> > > Bruce - > > The problem is that the index is useless, because you're

RE: Rewrite SQL to stop table scan

2011-01-14 Thread Jerry Schwartz
>-Original Message- >From: Bruce Ferrell [mailto:bferr...@baywinds.org] >Sent: Friday, January 14, 2011 5:53 AM >To: mysql@lists.mysql.com >Subject: Rewrite SQL to stop table scan > >How would you rewrite the following SQL so that is doesn't do a full >table

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Steve Meyers
On 1/14/11 3:52 AM, Bruce Ferrell wrote: select count(*) as count from alerts where (unix_timestamp(stamp)> (unix_timestamp(now()) - '300' ) ) and devid = '244'; Bruce - The problem is that the index is useless, because you're running a function on the timestamp. What you want is this: S

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Peter Brawley
On 1/14/2011 4:52 AM, Bruce Ferrell wrote: How would you rewrite the following SQL so that is doesn't do a full table scan. It does in fact do a full scan in spite of the time clause. It's been making me nuts for months. select count(*) as count from alerts where (unix_times

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Yogesh Kore
Hey, Try making `id` as primary key. That will keep data in sorted manner and scan will look only the data required in-spite of full table scan. On Fri, Jan 14, 2011 at 4:22 PM, Bruce Ferrell wrote: > How would you rewrite the following SQL so that is doesn't do a full > table scan

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Yogesh Kore
can you send DDL of the table? On Fri, Jan 14, 2011 at 4:22 PM, Bruce Ferrell wrote: > How would you rewrite the following SQL so that is doesn't do a full > table scan. It does in fact do a full scan in spite of the time > clause. It's been > making me nuts for months.

Re: Rewrite SQL to stop table scan

2011-01-14 Thread Johan De Meersman
ofill it with a trigger from stamp, or now() if that is appropriate. On Fri, Jan 14, 2011 at 11:52 AM, Bruce Ferrell wrote: > How would you rewrite the following SQL so that is doesn't do a full > table scan. It does in fact do a full scan in spite of the time > clause. It'

Rewrite SQL to stop table scan

2011-01-14 Thread Bruce Ferrell
How would you rewrite the following SQL so that is doesn't do a full table scan. It does in fact do a full scan in spite of the time clause. It's been making me nuts for months. select count(*) as count from alerts where (unix_timestamp(stamp) > (unix_timestamp(now()) - '

Re: replicate-rewrite-db

2008-04-04 Thread Dan Rogart
On Fri, Apr 4, 2008 at 6:30 AM, Shanmugam, Dhandapani < [EMAIL PROTECTED]> wrote: Hi, Hi, > > Any idea wat replicate-rewrite-db does with example.. > > > > It takes statements for one database, and rewrites them into another. An example of the syntax would be this li

replicate-rewrite-db

2008-04-04 Thread Shanmugam, Dhandapani
Hi, Any idea wat replicate-rewrite-db does with example..

Re: How to rewrite SQL query for new MySQL LEFT JOINS

2007-05-23 Thread Gmail User
It worked in 4.x but does not work in the new syntax. How should I rewrite it to get the same result? OK, that was a lie. It works in 5.x as well. I should learn to describe my problem more accurately as well as RTFM :-( The correct description of the query in question would have been: select

How to rewrite SQL query for new MySQL LEFT JOINS

2007-05-23 Thread Gmail User
ted < messages_.created where messages_.id is null It worked in 4.x but does not work in the new syntax. How should I rewrite it to get the same result? TIA, Ed -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: Re: RE: How to rewrite query

2006-10-18 Thread Dan Buettner
I'm not certain how MySQL handles the specific case where some columns in a record covered by a multi-column index are updated; it may update the whole index entry, or just part of it, not sure. In any case, yes, there is some overhead associated with having an index on columns that get updated.

Re: RE: How to rewrite query

2006-10-18 Thread Mindaugas
I agree that individual fields have relatively few possible values - hopefully, when those are combined in a multi-column index, he will have a greater number of unique combinations, gaining more out of the index. That's why I suggested putting stype and Is_id as the first two fields in the in

Re: How to rewrite query

2006-10-17 Thread Martin Skold
re 3 updates. But updates are of type "update something where ip=ipaddr" and ipaddr is unique key. What can cause slowdown in NDB case? Table is small and is in memory (5.0 cluster). Maybe I can rewrite it in some better form for such case? MySQL setting are basically default. I d

RE: RE: How to rewrite query

2006-10-17 Thread Jerry Schwartz
6 1:28 PM > To: mysql@lists.mysql.com > Subject: RE: RE: How to rewrite query > > Would it not be best to have the field with the fewest > repeats (i.e., the > closest to unique) first, or is that what you meant. > Bill > > On Tue, October 17, 2006 10:12, Jerry Schwartz said:

Re: RE: RE: How to rewrite query

2006-10-17 Thread Dan Buettner
ilto:[EMAIL PROTECTED] >> Sent: Tuesday, October 17, 2006 12:05 PM >> To: Jerry Schwartz >> Cc: mos; mysql@lists.mysql.com >> Subject: Re: RE: How to rewrite query >> >> I agree that individual fields have relatively few possible values - >> hopefully, when

RE: RE: How to rewrite query

2006-10-17 Thread William R. Mussatto
Farmington, CT 06032 > > 860.674.8796 / FAX: 860.674.8341 > > >> -Original Message- >> From: Dan Buettner [mailto:[EMAIL PROTECTED] >> Sent: Tuesday, October 17, 2006 12:05 PM >> To: Jerry Schwartz >> Cc: mos; mysql@lists.mysql.com >> Subject: Re

RE: RE: How to rewrite query

2006-10-17 Thread Jerry Schwartz
Subject: Re: RE: How to rewrite query > > I agree that individual fields have relatively few possible values - > hopefully, when those are combined in a multi-column index, he will > have a greater number of unique combinations, gaining more out of the > index. That's why I sug

Re: RE: How to rewrite query

2006-10-17 Thread Dan Buettner
6 / FAX: 860.674.8341 > -Original Message- > From: mos [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 17, 2006 10:46 AM > To: mysql@lists.mysql.com > Subject: Re: How to rewrite query > > At 08:34 AM 10/17/2006, you wrote: > > > Hello, > > >

RE: How to rewrite query

2006-10-17 Thread Jerry Schwartz
ington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 > -Original Message- > From: mos [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 17, 2006 10:46 AM > To: mysql@lists.mysql.com > Subject: Re: How to rewrite query > > At 08:34 AM 10/17/2006, you wr

Re: How to rewrite query

2006-10-17 Thread mos
lot of updates to ipaddr table too. For every select there are 3 updates. But updates are of type "update something where ip=ipaddr" and ipaddr is unique key. What can cause slowdown in NDB case? Table is small and is in memory (5.0 cluster). Maybe I can rewrite it in some better for

Re: Re: How to rewrite query

2006-10-17 Thread Dan Buettner
You should strongly consider adding an index on the fields you're querying against. Right now, none of the fields in your query are indexed in the table. I would try something like this for starters: a multi-column index against all the fields in the query you showed. If you have other queries

Re: How to rewrite query

2006-10-17 Thread Dan Buettner
B case? Table is small and is in memory (5.0 cluster). Maybe I can rewrite it in some better form for such case? MySQL setting are basically default. I did not find something in documentation about improving performance of NDB engine tables. Maybe increase read_buffer_size which is currently the

How to rewrite query

2006-10-17 Thread Mindaugas
. For every select there are 3 updates. But updates are of type "update something where ip=ipaddr" and ipaddr is unique key. What can cause slowdown in NDB case? Table is small and is in memory (5.0 cluster). Maybe I can rewrite it in some better form for such case? MySQL setting ar

Re: --replicate-rewrite-db fails when attempting to drop a table

2006-01-18 Thread Gleb Paharenko
gt; leave it this way, they therefore asked if it was possible to replicate to a > different database > name, e.g. livedb_backup. > > I suggested the use of the --replicate-rewrite-db option. > > When I set this up and tested it I decided to create a new table and then >

--replicate-rewrite-db fails when attempting to drop a table

2006-01-17 Thread Ian
the master and the customer wants to leave it this way, they therefore asked if it was possible to replicate to a different database name, e.g. livedb_backup. I suggested the use of the --replicate-rewrite-db option. When I set this up and tested it I decided to create a new table and then d

how to rewrite this query without using temporary table

2004-04-15 Thread Bill Easton
will have - a row for each appointment in the given range - a row for each patient who doesn't have an appointment Then the where clause throws away the ones with appointments. regards, Bill > From: "lorenzo.kh" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED

how to rewrite this query without using temporary table

2004-04-15 Thread lorenzo.kh
Hi,   I  have 2 tables.patientrecall_table and appointment_table.The patientrecall_table used to store what is the nextrecall date for the patient while the appointment_tablewill store all the appointments made.Now, I'd like to get through this:"Patients Due for Recall, but No Scheduled Appo

Re: Rewrite

2003-07-25 Thread mixo
Would table names still be case sensitive if the connection is done through odbc? Diana Soares wrote: Read the first item that appears in MySQL manual if you search for "case sensitivity": http://www.mysql.com/doc/en/Name_case_sensitivity.html -- MySQL General Mailing List For list archives: ht

Re: Rewrite

2003-07-24 Thread Diana Soares
On Thu, 2003-07-24 at 11:58, mixo wrote: > How can I write this query so it works on mysql 3.54: > > select groupmembers.memberid,users.name from groupmembers,users where > (not users.name='root') > and groupmembers.groupid=(select groups.id from > grou

Rewrite

2003-07-24 Thread mixo
How can I write this query so it works on mysql 3.54: select groupmembers.memberid,users.name from groupmembers,users where (not users.name='root') and groupmembers.groupid=(select groups.id from groups where groups.type='Privileged')

How to rewrite this query??

2003-05-29 Thread Inandjo Taurel
hi, i have the following query working perfectly with Dbase 4, but it crashes in mysql : SELECT SUM(DISTINCT A.AMOUNT) AS AMT FROM table1 A I'd like to get that amount in only one query if possible, even though i could do it by using a temporary table, selecting into it all the distinct amoun

replicate-rewrite-db

2003-02-19 Thread Arthur Kerpician
I have the same db on master and slave and I want to use replicate-rewrite-db to change the replicating name of this db on the slave. Slave my.cnf: --- [mysqld] datadir=/var/lib/mysql socket=/tmp/mysql.sock master-host=master.company.com master-user=repl master

re: syntax problem with replicate-rewrite-db

2002-11-20 Thread Victoria Reznichenko
David, Tuesday, November 19, 2002, 5:20:23 PM, you wrote: DN> (sorry if this is a duplicate -- I don't think the original made it) DN> Running mysql 3.23.53-max binary on a RedHat 7.2 based server. Replication DN> is working fine, but I'm running into errors with the repl

syntax problem with replicate-rewrite-db

2002-11-19 Thread David Nedved
Hi All, (sorry if this is a duplicate -- I don't think the original made it) Running mysql 3.23.53-max binary on a RedHat 7.2 based server. Replication is working fine, but I'm running into errors with the replicate-rewrite-db directive. Here's a snippet from my my.cnf fi

syntax problem with replicate-rewrite-db

2002-11-18 Thread David Nedved
Hi All, Running mysql 3.23.52-max binary on a RedHat 7.2 based server. Replication is working fine, but I'm running into errors with the replicate-rewrite-db directive. Here's a snippet from my my.cnf file on the slave: master-port = 3306 replicate-rewrite-db=mysql->maste

replicate-rewrite-db

2002-02-28 Thread David Cumming
Hello (Post 2) Has anyone got replicate-rewrite-db (a my.cnf entry) to work. I have replication running fine, however the rewrite doesn't work. I just want to know whether I should persist or if there is something special people had to do to get it working. I have heard / read a few p

replicate-rewrite-db

2002-02-25 Thread David Cumming
Hello Has anyone got replicate-rewrite-db (a my.cnf entry) to work. I have replication running fine, however the rewrite doesn't work. I just want to know whether I should persist or if there is something special people had to do to get it working. I have heard / read a few people saying

RE: How to rewrite this statement.

2002-02-22 Thread Salada, Duncan
PROTECTED] > Subject: Re: How to rewrite this statement. > > > Ok, so I updated the statement like the past few posts have > directed so the > statement looks like this: > > SELECT FORUMCAT1.LASTPOST, USERS.USERNAME, FORUMCAT1.ID, > FORUMCAT1.TOPIC, > FORUMCAT1.REPL

RE: How to rewrite this statement.

2002-02-22 Thread Rick Emery
: How to rewrite this statement. Ok, so I updated the statement like the past few posts have directed so the statement looks like this: SELECT FORUMCAT1.LASTPOST, USERS.USERNAME, FORUMCAT1.ID, FORUMCAT1.TOPIC, FORUMCAT1.REPLIES, FORUMCAT1.ORIGINATOR, FORUMCAT1.STATUS FROM USERS INNER JOIN

Re: How to rewrite this statement.

2002-02-22 Thread Mat Murdock
ON FORUMCAT1.ID = FORUMMSG1.POSTNUMBER)ON USERS' at line 1. Thanks, Mat - Original Message - From: "Nathan" <[EMAIL PROTECTED]> To: "Mat Murdock" <[EMAIL PROTECTED]> Sent: Friday, February 22, 2002 12:03 PM Subject: Re: How to rewrite this statement.

Re: How to rewrite this statement.

2002-02-22 Thread Rodney Broom
From: Mat Murdock <[EMAIL PROTECTED]> > ... Like "*java*" Try: Like "%java%" I would bet the the aseriscs are some non-SQL extention of MS Access. --- Rodney Broom Programmer: Desert.Net - Before posting, please check:

How to rewrite this statement.

2002-02-22 Thread Mat Murdock
I have this query that works just fine in msacess agains some linked mysql tables, but if I run this statement in php or in mysqlfront it doesn't work. I belive it's because there is two joins in it but i'm not sure. If that is the problem then what is the work around? Here is the statement: SE

UPDATE or 'rewrite' table with SELECT?

2001-09-22 Thread Nelson Goforth
ywords, kw_link WHERE locations.locationid = kw_link.locationid AND keywords.kwid = kw_link.kw_id GROUP BY kw_link.kw_id; ...but it appears that I can't use that to UPDATE the Keyword table. Ideally I'd simply update the LocationCount field in Keywords with the appropriate cou

RE: Sub-selects in a insert statement - is it possible to rewrite?

2001-06-25 Thread Chris Bolt
> This is how I'd like the query to work: > insert into host (host_id, host_IP) values ((select from mail > mail_id where > mail_addr = "[EMAIL PROTECTED]"), '127.0.0.1') Try: insert into host (host_id, host_IP) select mail_id, '127.0.0.1' from mail where mail_addr = '[EMAIL PROTECTED]'; -

Sub-selects in a insert statement - is it possible to rewrite?

2001-06-25 Thread Andreas D. Landmark
As I've understood it mysql doesn't support sub-selects inside for example insert statements (apart from inset ... select). Background-stuff: What I'm working on is parsing logfiles and inserting them into a mysql database through the C API, to minimize traffic and to maximize time, I was hopin