Getting next Birthdays

2006-09-06 Thread ESV Media GmbH

Hello MySQL-User,

i need your help with the following query.
I want to get the next birthdays of my friends, but not only the one of 
this year.
So when im in december ( or november ) i want to see the birthdays of 
next year too

With my query i only see the birthdays of this year :

SELECT SQL_CACHE DISTINCT fname,lname, mem.mem_id AS p_id, 
DATE_FORMAT(mem.birthday,'%d.%m') AS geburtstag,
DATEDIFF(DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y'),'-%m-%d')),DATE_FORMAT(NOW(),'%Y-%m-%d')) 
as tage

FROM members mem
INNER JOIN network n ON ( ( n.mid = 1 AND n.action = 1 AND 
n.bid=mem.mem_id ) OR ( n.bid = 1 AND n.action = 1 AND n.mid=mem.mem_id) )
WHERE DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL 1 DAY) <= 
DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y'),'-%m-%d'))

ORDER BY tage

Thx a lot !!!

Cheers

Marco

spacemarc schrieb:

2006/9/6, Miles Thompson <[EMAIL PROTECTED]>:

First of all - please reply to the list ..

I thought you wanted all fields, that's the way your SELECT statement is
constructed. If just the first 20 char from fieldA, then ...
 SELECT LEFT(fieldA, 20) AS fieldA FROM Tab1
should do what you want. Again, check the syntax for LEFT() in the 
MySQL docs.


the syntax is valid:
from http://dev.mysql.com/doc/refman/5.0/en/string-functions.html:
"LEFT(str,len) returns the leftmost len characters from the string
str, or NULL if any argument is NULL."
mysql> SELECT LEFT('foobarbar', 5);
   -> 'fooba'

I have 30 fields: instead writing all 30 fields, I would want to
select them all with * and only for one of they, fieldA, to obtain the
first 20 chars: it's possible?






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: SELECT counting chars with LEFT()

2006-09-06 Thread ESV Media GmbH

Hello MySQL-User,

i need your help with the following query.
I want to get the next birthdays of my friends, but not only the one of 
this year.
So when im in december ( or november ) i want to see the birthdays of 
next year too

With my query i only see the birthdays of this year :

SELECT SQL_CACHE DISTINCT fname,lname, mem.mem_id AS p_id, 
DATE_FORMAT(mem.birthday,'%d.%m') AS geburtstag,
DATEDIFF(DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y'),'-%m-%d')),DATE_FORMAT(NOW(),'%Y-%m-%d')) 
as tage

FROM members mem
INNER JOIN network n ON ( ( n.mid = 1 AND n.action = 1 AND 
n.bid=mem.mem_id ) OR ( n.bid = 1 AND n.action = 1 AND n.mid=mem.mem_id) )
WHERE DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL 1 DAY) <= 
DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y'),'-%m-%d'))

ORDER BY tage

Thx a lot !!!

Cheers

Marco

spacemarc schrieb:

2006/9/6, Miles Thompson <[EMAIL PROTECTED]>:

First of all - please reply to the list ..

I thought you wanted all fields, that's the way your SELECT statement is
constructed. If just the first 20 char from fieldA, then ...
 SELECT LEFT(fieldA, 20) AS fieldA FROM Tab1
should do what you want. Again, check the syntax for LEFT() in the 
MySQL docs.


the syntax is valid:
from http://dev.mysql.com/doc/refman/5.0/en/string-functions.html:
"LEFT(str,len) returns the leftmost len characters from the string
str, or NULL if any argument is NULL."
mysql> SELECT LEFT('foobarbar', 5);
   -> 'fooba'

I have 30 fields: instead writing all 30 fields, I would want to
select them all with * and only for one of they, fieldA, to obtain the
first 20 chars: it's possible?





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Need your Help : Degrees in network between members/friends

2006-08-22 Thread ESV Media GmbH

Hey everybody,

i´m becoming desperate about the following problem.
We´ve an online-community / network.
There´s a network table ( sql create below ), in which we store the 
relationships between the member.
I need a SQL-statement or a PHP-Function to calculate the 2nd, 3rd and 
4th degrees between the members.

So, the friends of my friends, the friends of them and so on.
I would really appreciate any help and would be so happy if you can help 
me with this problem :


Here is the function i´ve right now :


function getFriends($uid,$userself=0,$test=0){
$uid = mysql_real_escape_string(strip_tags($uid));
// Liefert alle "ersten grad Freunde" eines Members zurück


$res = mysql_query(" (
SELECT bid AS frd_id FROM network n
WHERE ( n.mid IN (".$uid.") AND n.bid NOT IN (".$uid.",$userself) )
)
UNION
(
SELECT mid AS frd_id FROM network n
WHERE ( n.mid NOT IN (".$uid.",$userself) AND n.bid IN (".$uid.") )
)",_CON);
$this->mySQLOptimizer("get friends");

if ($test==1)
{
die(" (
SELECT bid AS frd_id FROM network n
WHERE ( n.mid IN (".$uid.") AND n.bid NOT IN (".$uid.",$userself) )
)
UNION
(
SELECT mid AS frd_id FROM network n
WHERE ( n.mid NOT IN (".$uid.",$userself) AND n.bid IN (".$uid.") )
)");
}

$friends = array();
if ( mysql_num_rows($res) >= 1 )
{
while ($data = mysql_fetch_array($res))
$friends[] = $data["frd_id"];
}
else
{
$friends=0;
}
return $friends;
}

function getFriensdegrees($uid){
$uid = mysql_real_escape_string(strip_tags($uid));
// level 1 ermitteln

$retarry[1] = $this->getFriends($uid);
if (is_array($retarry[1]))
{
// level 2 ermitteln
$retarry[2] = $this->getFriends(explode(',',$retarry[1]),$uid,1);

if (is_array($retarry[2]))
{
$retarry[3] = $this->getFriends(explode(',',$retarry[2]),$uid);
}
else
{
$retarry[3] = "0";
}

if (is_array($retarry[3]))
{
$retarry[4] = $this->getFriends(explode(',',$retarry[3]),$uid);
}
else
{
$retarry[4] = "0";
}
$returnarray = array("1" => $retarry[1], "2" => $retarry[2], "3" => 
$retarry[3], "4" => $retarry[4]);

}
else
{
$returnarray = "";
}
return $returnarray;
}

function countfriensdegrees($uid){
$uid = mysql_real_escape_string(strip_tags($uid));
// level 1 ermitteln
$retarry[1] = $this->getFriends($uid);
if (count($retarry[1]) >= 1 && is_array($retarry[1]))
{
// level 2 ermitteln
$retarry[2] = $this->getFriends(implode(",",$retarry[1]),$uid);

if (is_array($retarry[2]))
{
$retarry[3] = $this->getFriends(implode(",",$retarry[2]),$uid);
}
else
{
$retarry[3] = "0";
}

if (is_array($retarry[3]))
{
$retarry[4] = $this->getFriends(implode(",",$retarry[3]),$uid);
}
else
{
$retarry[4] = "0";
}


/*
// level 3 ermitteln
foreach($members_lev2 as $value){
$res = gForum::return_friends($value);
foreach($res as $val) $members_lev3d[] = $val;
unset($res);
}
$members_lev3 = array_unique($members_lev3d);
$members_lev3 = array_diff($members_lev3, $members_lev2);
$members_lev3 = array_diff($members_lev3, $members_lev1);
$members_lev3 = array_diff($members_lev3, array("0" => $member));

// level 4 ermitteln
foreach($members_lev3 as $value){
$res = gForum::return_friends($value);
foreach($res as $val) $members_lev4d[] = $val;
unset($res);
}
$members_lev4 = array_unique($members_lev4d);
$members_lev4 = array_diff($members_lev4, $members_lev3);
$members_lev4 = array_diff($members_lev4, $members_lev2);
$members_lev4 = array_diff($members_lev4, $members_lev1);
$members_lev4 = array_diff($members_lev4, array("0" => $member));
*/
$retarray = array("1" => sizeof($retarry[1]), "2" => sizeof($retarry[2]));
}
else
{
$retarray = array("1" => 0, "2" => 0);
}
return $retarray;
}



Network Table :

bid is the id of the person i´ve connected.

DROP TABLE IF EXISTS `db80049_36`.`network`;
CREATE TABLE `db80049_36`.`network` (
`id` int(11) NOT NULL auto_increment,
`mid` int(11) NOT NULL default '0',
`bid` int(11) NOT NULL default '0',
`reason` longtext NOT NULL,
`action` int(1) NOT NULL default '0',
`sent` datetime NOT NULL default '-00-00 00:00:00',
`action_on` datetime NOT NULL default '-00-00 00:00:00',
`reason_decline` longtext NOT NULL,
PRIMARY KEY (`id`),
KEY `mid` (`mid`),
KEY `bid` (`bid`),
KEY `accepted` (`action`),
KEY `mid_bid_together` (`mid`,`bid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Degrees in network between members/friends

2006-08-18 Thread ESV Media GmbH

Hey everybody,

i´m becoming desperate about the following problem.
We´ve an online-community / network.
There´s a network table ( sql create below ), in which we store the 
relationships between the member.
I need a SQL-statement or a PHP-Function to calculate the 2nd, 3rd and 
4th degrees between the members.

So, the friends of my friends, the friends of them and so on.
I would really appreciate any help and would be so happy if you can help 
me with this problem :


Here is the function i´ve right now :


function getFriends($uid,$userself=0,$test=0){
$uid = mysql_real_escape_string(strip_tags($uid));
// Liefert alle "ersten grad Freunde" eines Members zurück


$res = mysql_query(" (
SELECT bid AS frd_id FROM network n
WHERE ( n.mid IN (".$uid.") AND n.bid NOT IN (".$uid.",$userself) )
)
UNION
(
SELECT mid AS frd_id FROM network n
WHERE ( n.mid NOT IN (".$uid.",$userself) AND n.bid IN (".$uid.") )
)",_CON);
$this->mySQLOptimizer("get friends");

if ($test==1)
{
die(" (
SELECT bid AS frd_id FROM network n
WHERE ( n.mid IN (".$uid.") AND n.bid NOT IN (".$uid.",$userself) )
)
UNION
(
SELECT mid AS frd_id FROM network n
WHERE ( n.mid NOT IN (".$uid.",$userself) AND n.bid IN (".$uid.") )
)");
}

$friends = array();
if ( mysql_num_rows($res) >= 1 )
{
while ($data = mysql_fetch_array($res))
$friends[] = $data["frd_id"];
}
else
{
$friends=0;
}
return $friends;
}

function getFriensdegrees($uid){
$uid = mysql_real_escape_string(strip_tags($uid));
// level 1 ermitteln

$retarry[1] = $this->getFriends($uid);
if (is_array($retarry[1]))
{
// level 2 ermitteln
$retarry[2] = $this->getFriends(explode(',',$retarry[1]),$uid,1);

if (is_array($retarry[2]))
{
$retarry[3] = $this->getFriends(explode(',',$retarry[2]),$uid);
}
else
{
$retarry[3] = "0";
}

if (is_array($retarry[3]))
{
$retarry[4] = $this->getFriends(explode(',',$retarry[3]),$uid);
}
else
{
$retarry[4] = "0";
}
$returnarray = array("1" => $retarry[1], "2" => $retarry[2], "3" => 
$retarry[3], "4" => $retarry[4]);

}
else
{
$returnarray = "";
}
return $returnarray;
}

function countfriensdegrees($uid){
$uid = mysql_real_escape_string(strip_tags($uid));
// level 1 ermitteln
$retarry[1] = $this->getFriends($uid);
if (count($retarry[1]) >= 1 && is_array($retarry[1]))
{
// level 2 ermitteln
$retarry[2] = $this->getFriends(implode(",",$retarry[1]),$uid);

if (is_array($retarry[2]))
{
$retarry[3] = $this->getFriends(implode(",",$retarry[2]),$uid);
}
else
{
$retarry[3] = "0";
}

if (is_array($retarry[3]))
{
$retarry[4] = $this->getFriends(implode(",",$retarry[3]),$uid);
}
else
{
$retarry[4] = "0";
}


/*
// level 3 ermitteln
foreach($members_lev2 as $value){
$res = gForum::return_friends($value);
foreach($res as $val) $members_lev3d[] = $val;
unset($res);
}
$members_lev3 = array_unique($members_lev3d);
$members_lev3 = array_diff($members_lev3, $members_lev2);
$members_lev3 = array_diff($members_lev3, $members_lev1);
$members_lev3 = array_diff($members_lev3, array("0" => $member));

// level 4 ermitteln
foreach($members_lev3 as $value){
$res = gForum::return_friends($value);
foreach($res as $val) $members_lev4d[] = $val;
unset($res);
}
$members_lev4 = array_unique($members_lev4d);
$members_lev4 = array_diff($members_lev4, $members_lev3);
$members_lev4 = array_diff($members_lev4, $members_lev2);
$members_lev4 = array_diff($members_lev4, $members_lev1);
$members_lev4 = array_diff($members_lev4, array("0" => $member));
*/
$retarray = array("1" => sizeof($retarry[1]), "2" => sizeof($retarry[2]));
}
else
{
$retarray = array("1" => 0, "2" => 0);
}
return $retarray;
}



Network Table :

bid is the id of the person i´ve connected.

DROP TABLE IF EXISTS `db80049_36`.`network`;
CREATE TABLE `db80049_36`.`network` (
`id` int(11) NOT NULL auto_increment,
`mid` int(11) NOT NULL default '0',
`bid` int(11) NOT NULL default '0',
`reason` longtext NOT NULL,
`action` int(1) NOT NULL default '0',
`sent` datetime NOT NULL default '-00-00 00:00:00',
`action_on` datetime NOT NULL default '-00-00 00:00:00',
`reason_decline` longtext NOT NULL,
PRIMARY KEY (`id`),
KEY `mid` (`mid`),
KEY `bid` (`bid`),
KEY `accepted` (`action`),
KEY `mid_bid_together` (`mid`,`bid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



[Fwd: Getting next birthdays]

2006-05-08 Thread ESV Media GmbH

Hey, i´ve a problem with getting the next and the actual birthdays.

This my actual birthday sql :

SELECT SQL_CACHE birthday,mem.lname, mem.fname,mem.mem_id FROM members mem
INNER JOIN network net ON (net.mem_id = mem.mem_id AND net.frd_id =1)
WHERE
(( DAYOFYEAR(FROM_UNIXTIME( mem.birthday )) < DAYOFYEAR(now()) 
)*DAYOFYEAR(CONCAT(YEAR(NOW()),'-12-31')))+DAYOFYEAR(FROM_UNIXTIME( 
mem.birthday )) >= DAYOFYEAR(now())
ORDER BY (( DAYOFYEAR(FROM_UNIXTIME( mem.birthday )))*DAYOFYEAR(CONCAT(YEAR(NOW()),'-12-31')))+DAYOFYEAR(FROM_UNIXTIME( 
mem.birthday )) LIMIT 4


The field birthday is in a Unix timestamp format.
I need the birthdays from yesterday, today and the next 4 or 5 birthdays.
And i need the table network to get my friends list.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Best Configuratuion ( my.cnf ) for a DB with many users and large columns ( Images in BLOB Columns ) on a Website]

2006-01-19 Thread ESV Media GmbH

Hey,

what do you think is the best configuration ( my.cnf ) for running a 
database,

which many users access at the same time ( Website - Portal ).
We´ve also saved our Pictures ( nearly 3.500 rows ) in our database.
Every coloumn is round about 60-70 Kbyte, so i had to use mediumblob 
columns.
There are 116 Tables and we have a primary key and an index on every 
table and use them

in ( i hope so ;-)  ) every statement.
Here i´ve a my.cnf from another website.
Would that be an good configuration ?
Thanks in advance

Marco

My.cnf :

# The MySQL server
[mysqld]
port= 3307
socket  = /tmp/mysql.sock
skip-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_cache = 500
sort_buffer_size = 24M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 24M
record_buffer=1M
log-slow-queries
long_query_time = 3
query_cache_size = 512M
max_connections = 500
join_buffer_size = 16M

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 25M
sort_buffer_size = 25M
read_buffer = 6M
write_buffer = 6M

[myisamchk]
key_buffer = 25M
sort_buffer_size = 25M
read_buffer = 6M
write_buffer = 6M

[mysqlhotcopy]
interactive-timeout




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Best Configuratuion ( my.cnf ) for a DB with many users and large columns ( Images in BLOB Columns ) on a Website

2006-01-19 Thread ESV Media GmbH

Hey,

what do you think is the best configuration ( my.cnf ) for running a 
database,

which many users access at the same time ( Website - Portal ).
We´ve also saved our Pictures ( nearly 3.500 rows ) in our database.
Every coloumn is round about 60-70 Kbyte, so i had to use mediumblob 
columns.
There are 116 Tables and we have a primary key and an index on every 
table and use them

in ( i hope so ;-)  ) every statement.
Here i´ve a my.cnf from another website.
Would that be an good configuration ?
Thanks in advance

Marco

My.cnf :

# The MySQL server
[mysqld]
port= 3307
socket  = /tmp/mysql.sock
skip-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_cache = 500
sort_buffer_size = 24M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 24M
record_buffer=1M
log-slow-queries
long_query_time = 3
query_cache_size = 512M
max_connections = 500
join_buffer_size = 16M

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 25M
sort_buffer_size = 25M
read_buffer = 6M
write_buffer = 6M

[myisamchk]
key_buffer = 25M
sort_buffer_size = 25M
read_buffer = 6M
write_buffer = 6M

[mysqlhotcopy]
interactive-timeout


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Import from another db....

2006-01-19 Thread ESV Media GmbH

Hi everyone,

how can i import a database export from another database.
I´ve got alway a permission error...
I used mysqlimport & mysqldump...

Thanks in advance

Marco Schierhorn

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Reload Problem -> "Mass-Reload" crashes DB

2006-01-14 Thread ESV Media GmbH

Thanks for your quick reply.
We use PHP.
I´ll try it with mysql_pconnect();
I´ve already thought about it.
What happens, when we´ve several 1000 Users online. Doesn´t it open too 
many connections ?

mysql_connect closes every connection after using.
Does mysql_pconnect() the same ?

Thanks a lot for your help

Marco

Tom Horstmann wrote:

Dear Marco,

i'm not sure, this can be solved by MySQL itself, but if you're e.g.
using php you may try to use mysql_pconnect () instead of
mysql_connect (). Please see
http://www.php.net/manual/en/function.mysql-pconnect.php
and
http://www.php.net/manual/en/function.mysql-connect.php

In your favourite server-side-language there may be other functions
for persistant database-connections.

hth,

TomH



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Reload Problem -> "Mass-Reload" crashes DB

2006-01-14 Thread ESV Media GmbH

Hey,

we´ve on 2 website the problem, that if you hit a several times F5 or 
hold it down to reload the site,

MySQL opens many connections and breaks down after a while.
How can we prevent this ?
I close every MySQL Session and i do an if-statement ( if there´s any 
open connect ) before i open a new mysql connect.

I appreciate any help or suggestions.

Thanks in advance.

Kind regards

Marco Schierhorn

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Image Storage -- Better to store them on the Filesystem or in the MySQL DB

2005-11-24 Thread ESV Media GmbH

Hey,

we´ve large amount of Images ( nearly 2 GB ).
And they will increase, cause or Editors will submit several articles a 
day where they´re allowed to upload

some new pics.
So, whats the better solution ? To store them in the filesystem ( with 
only the path in the db )

or to store them as BLOB´s in the DB.
When we decide to store them in the DB, we´ve thought about splitting 
larger Images ( > 64 K ) into several pieces into the db.
So, we´ve a simulated "streaming". I´ve seen it at 
http://php.dreamwerx.net/forums/viewtopic.php?t=6.


So, any recommendation is very welcome.I would really appreciate any of 
them.


Cheers

Marco





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Perfomance / Optimize ( Full Table Scans ) and Help with my.cnf

2005-11-22 Thread ESV Media GmbH

Thanks for your answer.
I´m alreay logging slow queries, i gather no results.
But when I take a look with the "MySQL Administrator" Tool
i see that there are many full table scans.
I want to discover which queries produce this full table scans.
I´ve read that in MySQL 5 full table scans are logged in the slow query 
log as well,

but where can i find them in my version MySQL 4.1.13 ?

Cheers

Marco



sheeri kritzer wrote:


I suggest checking out your slow query logs:

http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html

the queries are logged, so going into a client and running an explain
on the slow queries should help you out.

-Sheeri

On 11/21/05, ESV Media GmbH <[EMAIL PROTECTED]> wrote:
 


Hey, we´ve a site ( PHP ) where several 1.000 are online at the same time.
They´re running many sql statements.
Is there a way to find out which statements take a full table scan to
optimize them ?
We´ve a cpu percentage of nearly 50 % with only 30 Members online.
And i´ve seen that there are some full table scans.
Where can i investigate them ?

And i need some help with configuring the my.cnf.
Below you´ll find our one.
Which options should i optimize ? We´ve much free memory but our cpu is
working to half of the full capacity...

uname -a :

Linux m30s06db.ispgateway.de 2.4.29-grsec #10 SMP Mon Jul 4 14:26:46
CEST 2005 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux

And thats the my.cnf :

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together
with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is
/kunden/106120_40670/ms_appl/mysql_4.1.10a/var) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3307
socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3307
socket = /tmp/mysql.sock
skip-locking
key_buffer = 64M
max_allowed_packet = 1M
table_cache = 5M
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
record_buffer=1M
log-slow-queries
long_query_time = 3

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin

# required unique id between 1 and 232 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
# MASTER_USER=, MASTER_PASSWORD= ;
#
# where you replace , ,  by quoted strings and
#  by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 232 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = 
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = 
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = 
#
# The port the master 

Perfomance / Optimize ( Full Table Scans ) and Help with my.cnf

2005-11-21 Thread ESV Media GmbH

Hey, we´ve a site ( PHP ) where several 1.000 are online at the same time.
They´re running many sql statements.
Is there a way to find out which statements take a full table scan to 
optimize them ?

We´ve a cpu percentage of nearly 50 % with only 30 Members online.
And i´ve seen that there are some full table scans.
Where can i investigate them ?

And i need some help with configuring the my.cnf.
Below you´ll find our one.
Which options should i optimize ? We´ve much free memory but our cpu is 
working to half of the full capacity...


uname -a :

Linux m30s06db.ispgateway.de 2.4.29-grsec #10 SMP Mon Jul 4 14:26:46 
CEST 2005 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux


And thats the my.cnf :

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together 
with

# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is 
/kunden/106120_40670/ms_appl/mysql_4.1.10a/var) or

# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3307
socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3307
socket = /tmp/mysql.sock
skip-locking
key_buffer = 64M
max_allowed_packet = 1M
table_cache = 5M
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
record_buffer=1M
log-slow-queries
long_query_time = 3

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin

# required unique id between 1 and 232 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
# MASTER_USER=, MASTER_PASSWORD= ;
#
# where you replace , ,  by quoted strings and
#  by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 232 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = 
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = 
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = 
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = 
#
# binary logging - not required for slaves, but recommended
#log-bin

# Point the following paths to different dedicated disks
#tmpdir = /tmp/
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 1

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /kunden/106120_40670/ms_appl/mysql_4.1.10a/var/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = 
/kunden/106120_40670/ms_appl/mysql_4.1.10a/var/

#innodb_log_arch_dir = /kunden/106120_40670/ms_appl/mysql_4.1.10a/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high