RE: Here's an Idea for Re-Syncing Master and Slave During Production Hours without Interrupting Users (Much)

2009-12-09 Thread Robinson, Eric
Hi Baron,

> I'm the primary author of Maatkit.  

Awkward... :-)

> What can I say -- you could go buy a commercial off-the-shelf tool 
> and believe the song and dance they feed you about the tool 
> being perfect.  

There's not a single commercial software solution in our toolbox. We're
big fans of CentOS, LVS, heartbeat, ldirectord, tomcat, MySQL, Xen,
pureFTP, and more. We've been happy with the performance and reliability
of all of our FOSS tools. I'm definitely not a Kool-aid drinker when it
comes to commercial product marketing.

> At least with Maatkit, you get transparency.  We make a concerted 
> effort to update the RISKS section of each tool with each release, so
there 
> is full disclosure.

Fair enough, but I still found the warnings a little too scary. A more
complete explanation of the exact nature of the bugs and the exact
circumstances under which I should be concerned about triggering them
would have increased my comfort level.  

> I think Maatkit is by far the best solution for live master-slave sync

> in most real-world situations.

We'll give it another look.

--
Eric Robinson



Disclaimer - December 9, 2009 
This email and any files transmitted with it are confidential and intended 
solely for Baron Schwartz,Gavin Towey,Tom Worster,my...@lists.mysql.com. If you 
are not the named addressee you should not disseminate, distribute, copy or 
alter this email. Any views or opinions presented in this email are solely 
those of the author and might not represent those of . Warning: Although  has 
taken reasonable precautions to ensure no viruses are present in this email, 
the company cannot accept responsibility for any loss or damage arising from 
the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Missing Entries

2009-12-09 Thread Neil Aggarwal
Carlos:

> I was checking my fresh install of MySQL and noticed I had empt spaces
> or missing entries in some sections when I did a search for users on
> the 'mysql' database.

According to this page:
http://dev.mysql.com/doc/mysql-security-excerpt/5.4/en/default-privileges.ht
ml
  If you want to prevent clients from connecting as anonymous users 
  without a password, you should either assign a password to each 
  anonymous account or else remove the accounts. 

We I do a MySQL install, I always go into the mysql client as root 
and issue these commands:
  use mysql;
  delete from user where Password='';
  flush privileges;
  quit;

It removes those accounts.

Neil

--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your MySQL database on a CentOS VPS for $25/mo
Unmetered bandwidth = no overage charges, 7 day free trial


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Missing Entries

2009-12-09 Thread John Daisley
I'm on my mobile so can't give you a link but you should read the reference 
manual section on 
'post-installation setup and testing'.

Regards
John Daisley.

-Original Message-
From: Carlos Williams 
Sent: 09 December 2009 21:16
To: mysql@lists.mysql.com
Subject: Missing Entries

I was checking my fresh install of MySQL and noticed I had empt spaces
 or missing entries in some sections when I did a search for users on
 the 'mysql' database. I checked the MySQL FAQ's and Google and nothing
 gave me what I am looking for. I can't understand what this entries
 are blank for:

 mysql> select User, Password, Host, Insert_priv from user;
 
++---+---+-+
 | User   | Password  | Host  | Insert_priv 
|
 
++---+---+-+
 | root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | localhost | Y   
|
 | root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | mail  | Y   
|
 | root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | 127.0.0.1 | Y   
|
 |    |   | localhost | N   
|
 |    |   | mail  | N   
|
 | carlos | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | localhost | N   
|
 
++---+---+-+

 I see there are 3 root users:

 - localhost
 - mail (hostname)
 - 127.0.0.1 (localhost IP)

 But after that there are two entries that are blank for 'localhost' &
 'mail'. Does anyone know what they are and if I can remove them. They
 appear useless and clutter my database. Sorry, I am OCD.

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    
http://lists.mysql.com/mysql?unsub=john.dais...@butterflysystems.co.uk



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Missing Entries

2009-12-09 Thread Carlos Williams
I was checking my fresh install of MySQL and noticed I had empt spaces
or missing entries in some sections when I did a search for users on
the 'mysql' database. I checked the MySQL FAQ's and Google and nothing
gave me what I am looking for. I can't understand what this entries
are blank for:

mysql> select User, Password, Host, Insert_priv from user;
++---+---+-+
| User   | Password  | Host  | Insert_priv |
++---+---+-+
| root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | localhost | Y   |
| root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | mail  | Y   |
| root   | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | 127.0.0.1 | Y   |
||   | localhost | N   |
||   | mail  | N   |
| carlos | *FDCCC9BE5FC366E7D9714988DBC7F111A950C428 | localhost | N   |
++---+---+-+

I see there are 3 root users:

- localhost
- mail (hostname)
- 127.0.0.1 (localhost IP)

But after that there are two entries that are blank for 'localhost' &
'mail'. Does anyone know what they are and if I can remove them. They
appear useless and clutter my database. Sorry, I am OCD.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Use stored proc result set from another stored proc without temp table?

2009-12-09 Thread Bryan Cantwell
I have a stored proc I need to call from yet another stored proc, which 
then needs to use the results from the called proc ... I could probably 
use temp table but really dont want to do that unless absolutely 
required. I cant use OUT parameters, because the called stored proc 
returns multiple rows.. can this be done (see the two samples below)  or 
is a temp table the only way?


This generates a result set
DELIMITER $$

DROP PROCEDURE IF EXISTS `getCMDBdata`$$
CREATE PROCEDURE `getCMDBdata`(IN ipadd VARCHAR(16))
BEGIN
DECLARE iid text;
select ifnull(group_concat(distinct `ia`.`ITEMID`),'0') into iid
from `federated_itemattributes` `ia` left join 
`federated_attributesvarchar2` `v` on(`ia`.`ITEMATTRIBUTEID` = 
`v`.`ITEMATTRIBUTEID`)

where v.value = ipadd and ia.typeattributeid = 8259;

SELECT   i.itemid, i.typeattributeid, i.itemattributeid, `VALUE`
 , y.typeid
 , y.datatypeid
 , y.description
 , p.typename
FROM federated_itemattributevalues i
 join itemattributes a on a.itemattributeid = i.itemattributeid
 join items t on t.itemid = i.itemid
 join typeattributes y on y.typeattributeid = i.typeattributeid
 join types p on p.typeid = y.typeid
 left outer join relationships r on r.ci1 = i.itemid and 
r.relationshiptypeid  IN (2667, 2684, 2704)

WHERE  r.ci1 IN (iid) OR ci2 IN (iid)
ORDER BY i.itemid, y.typeid;

END$$

DELIMITER ;


This calls the above proc and will eventually want to do things with the 
results:


DELIMITER $$

DROP PROCEDURE IF EXISTS `getMatch`$$
CREATE PROCEDURE `getMatch`()
BEGIN
DECLARE done0 INT DEFAULT 0;
DECLARE CID   BIGINT (20);
DECLARE HIP   VARCHAR (16);
DECLARE cur1 CURSOR FOR select distinct hostid, ip from hosts;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done0 = 1;

OPEN cur1;
REPEAT
FETCH cur1 INTO CID,HIP;
IF NOT done0 THEN
CALL `getCMDBdata`(HIP);
/* Do something with result above*/
END IF;
UNTIL done0
END REPEAT;
CLOSE cur1;

END$$

DELIMITER ;


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Select from remote server from stored procedure

2009-12-09 Thread Neil Aggarwal
Steve:

> I suppose maybe making this a slave table 
> to the other
> server... nah... lots of work there

Setting your local server to be a slave of the
remote server is not too hard and would
be a MUCH better solution.

The steps are fairly staightforward:

1. Add a slave user to the remote database
2. Tell the remote server to create a binary
log
3. Tell the local server to be a slave of
the remote
4. Start the slave

It should take less than 1 hour to set it up.
I have done it many times.  It is probably not
as hard as you are thinking it will be.

Neil


--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your MySQL database on a CentOS VPS for $25/mo
Unmetered bandwidth = no overage charges, 7 day free trial


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Select from remote server from stored procedure

2009-12-09 Thread Steven Staples
So what I am reading, I guess it would be safer to just do it how I am
currently doing it, as it really isn't that slow... it's just duplicating
the data elsewhere (I suppose maybe making this a slave table to the other
server... nah... lots of work there :P)

Thanks, and I did search it before, but I guess my searching keywords were
insufficient ;)


Steven Staples


-Original Message-
From: harrison.f...@sun.com [mailto:harrison.f...@sun.com] 
Sent: December 9, 2009 2:07 PM
To: Johan De Meersman
Cc: Neil Aggarwal; Steven Staples; mysql@lists.mysql.com
Subject: Re: Select from remote server from stored procedure

Hello Johan,

On Dec 9, 2009, at 11:22 AM, Johan De Meersman wrote:

> Posted this before, but beware: federated tables do NOT use indices.  
> Every
> select is a full table scan, and if you're talking about a logging  
> table
> that could become very expensive very fast.

This is not entirely true.  If you define an index on the local  
federated table, and it makes sense to use it, then a remote WHERE  
clause will be passed through and hence use the remote index.  Not all  
types of index accesses can be passed through such as this, however  
for a single row lookup on a primary key, it should be fine.

It is still not as fast as local access, but it's not as bad as always  
doing a full table scan remotely.

> On Wed, Dec 9, 2009 at 4:13 PM, Neil Aggarwal  
> wrote:
>
>>> Is this possible to do?  To make a connection, inside the
>>> stored procedure
>>> to a completely different machine and access the mysql there?
>>
>> The only way I know to access tables from different servers
>> from a single connection is federated tables:
>> http://dev.mysql.com/doc/refman/5.0/en/federated-use.html
>>
>> Once you do that, you are accessing it like a local table.
>>
>> I hope this helps.
>>
>>   Neil

Regards,

Harrison
-- 
Harrison C. Fisk, MySQL Staff Support Engineer
MySQL @ Sun Microsystems, Inc., http://www.sun.com/mysql/





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=sstap...@mnsi.net

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.709 / Virus Database: 270.14.97/2550 - Release Date: 12/09/09
02:32:00


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Joerg:

> A matching column is called an "equijoin"
> However, that is not mandatory / the only form.
> As long as the problem can be solved using ranges (or multiple ranges)
> which do not overlap, the join should solve it.

I just learned something. Thanks for the info!

Neil

--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your MySQL database on a CentOS VPS for $25/mo
Unmetered bandwidth = no overage charges, 7 day free trial


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: login problem from django script, using python2.5/MySQLdb/connections.py

2009-12-09 Thread Gavin Towey
Access Denied means you're using an incorrect username and password 
combination.  Test your credentials using the mysql cli.  You can log in as 
root to mysql to make changes as necessary, or supply the correct user/pass 
from your script.

Regards,
Gavin Towey

-Original Message-
From: John Griessen [mailto:j...@industromatic.com]
Sent: Wednesday, December 09, 2009 10:16 AM
To: mysql@lists.mysql.com
Subject: login problem from django script, using 
python2.5/MySQLdb/connections.py

If I can login from a shell, what could stop a script from login?

I'm following a newbie tutorial for django, a web content mgt. system.

The following user and password are good if I use them fromthe same shell the 
script launches from.

Here's the error message from a django script using a python module about mysql:


File "/usr/lib/pymodules/python2.5/MySQLdb/connections.py", line 170, in 
__init__
 super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1044, "Access denied for user 
'django_editor'@'%' to database 'django_server'")



Any ideas?

thanks,

John

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=gto...@ffn.com


This message contains confidential information and is intended only for the 
individual named.  If you are not the named addressee, you are notified that 
reviewing, disseminating, disclosing, copying or distributing this e-mail is 
strictly prohibited.  Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your system. 
E-mail transmission cannot be guaranteed to be secure or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any loss or damage caused by viruses or errors or omissions in the contents 
of this message, which arise as a result of e-mail transmission. [FriendFinder 
Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089, USA, FriendFinder.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: login problem from django script, using python2.5/MySQLdb/connections.py

2009-12-09 Thread John Griessen

John Griessen wrote:

If I can login from a shell, what could stop a script from login?


privileges were stopping it and at first, maybe a mistake in GRANT setup of a 
new user.

Nevermind

JG

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Select from remote server from stored procedure

2009-12-09 Thread Harrison Fisk

Hello Johan,

On Dec 9, 2009, at 11:22 AM, Johan De Meersman wrote:

Posted this before, but beware: federated tables do NOT use indices.  
Every
select is a full table scan, and if you're talking about a logging  
table

that could become very expensive very fast.


This is not entirely true.  If you define an index on the local  
federated table, and it makes sense to use it, then a remote WHERE  
clause will be passed through and hence use the remote index.  Not all  
types of index accesses can be passed through such as this, however  
for a single row lookup on a primary key, it should be fine.


It is still not as fast as local access, but it's not as bad as always  
doing a full table scan remotely.


On Wed, Dec 9, 2009 at 4:13 PM, Neil Aggarwal  
wrote:



Is this possible to do?  To make a connection, inside the
stored procedure
to a completely different machine and access the mysql there?


The only way I know to access tables from different servers
from a single connection is federated tables:
http://dev.mysql.com/doc/refman/5.0/en/federated-use.html

Once you do that, you are accessing it like a local table.

I hope this helps.

  Neil


Regards,

Harrison
--
Harrison C. Fisk, MySQL Staff Support Engineer
MySQL @ Sun Microsystems, Inc., http://www.sun.com/mysql/





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Join on a where clause.

2009-12-09 Thread Joerg Bruehe
Hi everybody!


Neil Aggarwal wrote:
> Paul:
> 
>> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip),
>> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN
>> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN
>> 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER
>> BY count DESC LIMIT 20;

I am surprised by the quotes you have around the "start_ip" and "end_ip"
columns; to me, this makes that look like strings.

From your posting, I see the result you hope to get but not the one you
actually get. IMO, just dropping the single quotes around the two column
names should produce the data you want to get.

Or what is the result you receive?

> 
> Hmm..  The hard part is that your mappings
> table is not a list of all IP addresses.
> It has a range from start to end, but the
> actual IP in the event table is not listed
> there.
> 
> Joins require a column value from each table
> to match.  That is not the case for you.

A matching column is called an "equijoin" (from "equality") in SQL
slang, and this is the most common form of a join. (Also, it is the
fastest, if there are suitable indices which can be used.)
However, that is not mandatory / the only form.

You can have a join with any predicate combining columns of the (two)
involved tables.
You can even have a join without any such predicate, which means every
combination of any two rows of the tables is to be returned. This is
known as "Cartesian Product" and is in most cases not what you want.

> 
> I think you are going to have to do this in
> your application code.

I never dealt with the assignment of IP addresses to countries.
As long as the problem can be solved using ranges (or multiple ranges)
which do not overlap, the join should solve it.


Regards,
Jörg

-- 
Joerg Bruehe,  MySQL Build Team,  joerg.bru...@sun.com
   (+49 30) 417 01 487
Sun Microsystems GmbH,   Komturstraße 18a,   D-12099 Berlin
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



login problem from django script, using python2.5/MySQLdb/connections.py

2009-12-09 Thread John Griessen

If I can login from a shell, what could stop a script from login?

I'm following a newbie tutorial for django, a web content mgt. system.

The following user and password are good if I use them fromthe same shell the 
script launches from.

Here's the error message from a django script using a python module about mysql:


File "/usr/lib/pymodules/python2.5/MySQLdb/connections.py", line 170, in 
__init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1044, "Access denied for user 
'django_editor'@'%' to database 'django_server'")



Any ideas?

thanks,

John

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Select from remote server from stored procedure

2009-12-09 Thread Johan De Meersman
Posted this before, but beware: federated tables do NOT use indices. Every
select is a full table scan, and if you're talking about a logging table
that could become very expensive very fast.

On Wed, Dec 9, 2009 at 4:13 PM, Neil Aggarwal wrote:

> > Is this possible to do?  To make a connection, inside the
> > stored procedure
> > to a completely different machine and access the mysql there?
>
> The only way I know to access tables from different servers
> from a single connection is federated tables:
> http://dev.mysql.com/doc/refman/5.0/en/federated-use.html
>
> Once you do that, you are accessing it like a local table.
>
> I hope this helps.
>
>Neil
>
> --
> Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
> Host your MySQL database on a CentOS VPS for $25/mo
> Unmetered bandwidth = no overage charges, 7 day free trial
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be
>
>


RE: Select from remote server from stored procedure

2009-12-09 Thread Neil Aggarwal
> Is this possible to do?  To make a connection, inside the 
> stored procedure
> to a completely different machine and access the mysql there?

The only way I know to access tables from different servers
from a single connection is federated tables:
http://dev.mysql.com/doc/refman/5.0/en/federated-use.html

Once you do that, you are accessing it like a local table.

I hope this helps.

Neil

--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your MySQL database on a CentOS VPS for $25/mo
Unmetered bandwidth = no overage charges, 7 day free trial


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Select from remote server from stored procedure

2009-12-09 Thread Steven Staples
Ok, I feel silly for asking this, but I am going to do it anyway.

I have a huge stored procedure that does quite a bit of logic, and
gathering/splitting of data.   I currently have our customer database on one
server, and our logging on another.  What i need to do, is to pull the
customer id from the other server, so that the logs are tied back to the
customer.

Is this possible to do?  To make a connection, inside the stored procedure
to a completely different machine and access the mysql there?

Does my question make sense?   Currently what I am doing, is every new
customer that gets created, my php app adds the username/customerid to that
server, then makes a connection to the logging server and creates the same
record, same with deleting and updating... but there just has to be a
simpler way :)

Thanks in advance.


Steven Staples




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Paul:

> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip),
> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN
> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN
> 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER
> BY count DESC LIMIT 20;

Hmm..  The hard part is that your mappings
table is not a list of all IP addresses.
It has a range from start to end, but the
actual IP in the event table is not listed
there.

Joins require a column value from each table
to match.  That is not the case for you.

I think you are going to have to do this in
your application code.

I hope this helps,
Neil

--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your MySQL database on a CentOS VPS for $25/mo
Unmetered bandwidth = no overage charges, 7 day free trial


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Join on a where clause.

2009-12-09 Thread Paul Halliday
I have 2 tables:

1) Event Data
2) Mappings

The query should return something like this:

Hits  IP  Country Code
20213.136.52.29 SE

I am trying this:

SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip),
mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN
'2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN
'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER
BY count DESC LIMIT 20;

Am I supposed to do a join somewhere? Do joins even apply in a where
clause? or am I totally off the mark.

Singularly, the queries look like this:

SELECT cc FROM mappings WHERE INET_ATON('src_ip') BETWEEN start_ip AND end_ip;

SELECT COUNT(src_ip) AS count, INET_NTOA(src_ip) FROM event WHERE
timestamp BETWEEN '2009-12-06 20:00' and '2009-12-07 20:00:00' GROUP
BY src_ip ORDER BY count DESC LIMIT 20;


Thanks.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: MySQL variables

2009-12-09 Thread Jesper Wisborg Krogh

On 09/12/2009, at 6:56 PM, machiel.richards wrote:


Good day guys (and girls if any)



I am constantly in a position where variables on a
production mysql database needs to be changed.



The database runs a 24/7 system and thus to reboot  
is not

preffered and should be the absolute last resort.



How can I set variables to be effective  
immediately?   ( I

am still a junior in mysql dba and still learning)


If you take a look at the manual in the section about server options  
and variables (http://dev.mysql.com/doc/refman/5.0/en/mysqld-option- 
tables.html in MySQL 5.0 or http://dev.mysql.com/doc/refman/5.1/en/ 
mysqld-option-tables.html in MySQL 5.1), then you can see which  
settings can be changed dynamically. To change a variable dynamically  
you need to have super privilege, and then set the variable as e.g.


SET GLOBAL system_var_name = ...



If I set these will it still be effective should the
database be restarted somewhere in the future?


The change above will not persist when the database is restarted. In  
order to ensure that, you will have to update the configuration file  
as well.


- Jesper





Thanks in advance for your help.



Regards








--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Force index command in sql query

2009-12-09 Thread Jesper Wisborg Krogh

On 09/12/2009, at 5:10 PM, Jeetendra Ranjan wrote:


Hi,

After analysing slow query log i found that some queries are not  
using index and so i used the force index command in query and test  
it and now it starts using index properly.Accordingly i implemented  
the same query with force index in my application code and  
regeneratet the slow query log. Now i found that the same queries  
having force index clause are againg not using index and  
surprisingly its starting using index without any force index clause.


Please suggest how it happened and should i continue with the force  
index command in that query or remove the force index clause from  
those queries ?


One of the things to be aware of is that "force index" only forces  
the index if the optimizer chooses to use an index. That is, if the  
optimizer decides it is better to do a table scan or the join order  
changes so the index cannot be used, then it will not use it. It  
might be worth trying to do an "EXPLAIN EXTENDED ..." followed by  
"SHOW WARNINGS" to see how the optimizer has reorganized the query.


Hope that helps.

- Jesper




Thanks & Regards
Jeetendra Ranjan





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org