Tag Archives: mysql

MSSQL How long will data be in cache/buffer

How fast is data leving the cache, when it not access again.

With this query, you can see how fast data will get expire, and overwritten by new data in the cache.

SELECT  @@servername AS INSTANCE
,[object_name]
,[counter_name]
, UPTIME_MIN = CASE WHEN[counter_name]= 'Page life expectancy'
          THEN (SELECT DATEDIFF(MI, MAX(login_time),GETDATE())
          FROM   master.sys.sysprocesses
          WHERE  cmd='LAZY WRITER')
      ELSE ''
END
, [cntr_value] AS PLE_SECS
,[cntr_value]/ 60 AS PLE_MINS
,[cntr_value]/ 3600 AS PLE_HOURS
,[cntr_value]/ 86400 AS PLE_DAYS
FROM  sys.dm_os_performance_counters
WHERE   [object_name] LIKE '%Manager%'
          AND[counter_name] = 'Page life expectancy'

Witch the query you can see how long time data will be in the cache/buffer.

Pureftpd (Ubuntu / Debian)

Setting up Pure ftpd to run on certains port is very simple.
Log on to you linux box and run this command:

echo “60010 60030” > /etc/pure-ftpd/conf/PassivePortRange
/etc/init.d/pure-ftpd restart

or if you run mysql as a backend

/etc/init.d/pure-ftpd-mysql restart

Now you just need to forward port 60010 to 60030, to you linux box.

Tweaking mySQL in Debian

This guide is not complete to tweak you mySQL on Debian systems, because a good tweak is depending on what you want to use mySQL to.

Key Buffer:
The key buffer holds the indexes of tables in memory, and of cause a bigger key buffer result in faster row lookups. The bigger this value is the better is it, but preventing swaping. good rule of thumb seems to be to use 1/4 of system memory. key_buffer = 256M

Query Cache:
query_cache_size, as the name say it is the total memory available to query caching. query_cache_limit is the maximum number of kilobytes one query may be in order to be cached. If you set this value to high it will prevent a lot of small query to be cached. Setting it to low will prevent bigger query to be cached.
query_cache_size = 128MB
query_cache_limit = 4MB

Table Cache:
If you application need to open a lot of tables, a important variable is table_cache, it is the number of tables a thread can keep open at the same time.
table_cache = 512

The InnoDB Engine:
Allmost everybody do not use InnoDB engine I mySQL, there are using MyISAM istead. Mysql reserved memory for InnoDB, so you could easy skip this Add skip-innodb to you my.cnf file.

Binary Logging:
If you don’t want to replicate data changes to a second server, and don’t use the binary logging as incredimental backup, you can disable this feature.
Comment out this line:
log_bin = /var/log/mysql/mysql-bin.log

[ad]

mySQL kommandoer i PHP

Lidt kommandoer til at arbejde med mySQl
Koble sig til en mySQL server
$mysql_server = “localhost”;
$mysql_bruger = “bruger”;
$mysql_password = “password”;
$mysql_database = “database”;
if (!mysql_connect(“$mysql_server”,”$mysql_bruger”,”$mysql_password”)) {
echo(“Kunne ikke oprette en forbindelse til MySQL.”);
exit;
}
if(!mysql_select_db(“$mysql_database”)) {
echo(“Kunne ikke vælge databasen: $database”);
exit;
}

Hente data ud fra en mySQL
$sql = mysql_query(“SELECT * FROM table”);
while ($rs = mysql_fetch_array($sql)) {
}