IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Administration MySQL Discussion :

Une entrée de trop


Sujet :

Administration MySQL

  1. #1
    Membre à l'essai
    Inscrit en
    Juin 2009
    Messages
    24
    Détails du profil
    Informations forums :
    Inscription : Juin 2009
    Messages : 24
    Points : 12
    Points
    12
    Par défaut Une entrée de trop
    BOnjour,

    Etude de cas (mon petit cas)

    Base de donnée : 3 tables
    2 avec 61200 entrées
    1 avec environ 5 000 entrées.

    Pas de requêtes slow (3sec).

    J'ai vérifié le type et la taille des variables des différentes tables, pas de problème de ce coté.

    Voilà avec les données si dessus, le serveur tourne convenablement.
    Avec mysqld %CPU : de 40 à 200 (fluctuent) et RAM : 7 - 9%.

    Si j'ajoute une entrée :
    2 tables avec 61201 entrées
    1 table avec environ 5 000 entrées.

    Le serveur rame fort apres quelques secondes:
    mysqld %CPU au dessus de 200% et la RAM plus de 40%, plus swap à donf !

    Pour conclure je retire une entrée, et la situation se rétablie.

    Je vois vraiment pas ou chercher, alors même si vous avez une simple piste je suis preneur.

    Merci part avance.

  2. #2
    Modérateur

    Avatar de CinePhil
    Homme Profil pro
    Ingénieur d'études en informatique
    Inscrit en
    Août 2006
    Messages
    16 799
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur d'études en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2006
    Messages : 16 799
    Points : 34 031
    Points
    34 031
    Billets dans le blog
    14
    Par défaut
    Ca rame à quel moment ?
    1) A l'insertion ?
    2) Une fois l'entrée effectuée et sur une requête SELECT ?

    Si 2), quelle requête ?

    Les tables sont correctement indexées ?

    Il n'y a pas de problème d'espace sur la partition qui stocke les données ?
    Philippe Leménager. Ingénieur d'étude à l'École Nationale Supérieure de Formation de l'Enseignement Agricole. Autoentrepreneur.
    Mon ancien blog sur la conception des BDD, le langage SQL, le PHP... et mon nouveau blog sur les mêmes sujets.
    « Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
    À la maison comme au bureau, j'utilise la suite Linux Mageïa !

  3. #3
    Membre à l'essai
    Inscrit en
    Juin 2009
    Messages
    24
    Détails du profil
    Informations forums :
    Inscription : Juin 2009
    Messages : 24
    Points : 12
    Points
    12
    Par défaut
    merci de ton attention pour mon cas.

    Je m'explique, la db tourne pour un siteweb (gallerie d'image).
    Le site tourne bien jusqu'a ce que j'ajoute encore une nouvelle entrer en l'occurance
    en passant de 61200 entrées à 61201.

    Coté utilisateur du site, il n'y a que des SELECT du type :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    SELECT T_poster.id, T_poster.file, T_poster.dater, FC_ratings.hits, FC_ratings.total_votes,
    FC_name.name, FC_name.country, FC_name.id AS IDName
    FROM  FC_poster AS T_poster
    LEFT JOIN FC_name ON (T_poster.id_name = FC_name.id)
    LEFT JOIN FC_ratings ON (T_poster.id = FC_ratings.id)
    WHERE FC_name.born <= '$dateMoin18'
    ORDER BY T_poster.dater DESC
    LIMIT  $begin,$NB_IMAGE_AFFICHER
    Avant l'ajout de cette ultime entrée voila une image representative de mon "top"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
     
    top - 17:40:11 up 12 days, 23:27,  1 user,  load average: 1.82, 2.05, 2.51
    Tasks: 713 total,   2 running, 711 sleeping,   0 stopped,   0 zombie
    Cpu(s): 17.4%us,  9.6%sy,  0.0%ni, 46.5%id, 24.2%wa,  0.3%hi,  2.0%si,  0.0%st
    Mem:   8091116k total,  8038320k used,    52796k free,   650700k buffers
    Swap:  2096472k total,    30604k used,  2065868k free,  2766456k cached
     
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    18012 mysql     20   0 1440m 1.2g 5204 S   80 15.7   1030:18 mysqld
    22333 www-data  20   0  224m 8760 3588 S    2  0.1   0:01.52 apache2
    22539 www-data  20   0  229m  12m 3640 S    2  0.2   0:01.43 apache2
    12962 www-data  20   0  226m  10m 3608 S    1  0.1   0:03.69 apache2
    18335 www-data  20   0  226m  10m 3648 S    1  0.1   0:14.88 apache2
    22030 www-data  20   0  224m 8672 3596 S    1  0.1   0:01.29 apache2
    22045 www-data  20   0  223m 7924 3600 S    1  0.1   0:01.48 apache2
    16676 www-data  20   0  226m  10m 3648 S    1  0.1   0:14.09 apache2
     5043 www-data  20   0  226m  10m 3648 S    1  0.1   0:07.33 apache2
    10901 www-data  20   0  226m  10m 3640 S    1  0.1   0:04.86 apache2
    13062 www-data  20   0  226m  11m 3956 S    1  0.1   0:15.76 apache2
    13291 www-data  20   0  226m  10m 3648 S    1  0.1   0:03.61 apache2
    16678 www-data  20   0  226m  10m 3776 D    1  0.1   0:15.79 apache2
    19616 www-data  20   0  224m 8784 3600 S    1  0.1   0:01.80 apache2
    22052 www-data  20   0  224m 8624 3620 S    1  0.1   0:01.31 apache2
    24505 www-data  20   0  224m 7952 3588 S    1  0.1   0:00.63 apache2
    24556 root      20   0 19384 1776  932 R    1  0.0   0:08.37 top
    25790 www-data  20   0  226m  10m 3676 S    1  0.1   0:11.07 apache2
    30176 root      20   0 16700  260  144 S    1  0.0  12:15.81 rotatelogs
     5082 www-data  20   0  226m  10m 3648 S    0  0.1   0:06.79 apache2
     5232 www-data  20   0  226m  10m 3660 S    0  0.1   0:06.74 apache2
     7884 www-data  20   0  226m  10m 3880 S    0  0.1   0:05.60 apache2
     7939 www-data  20   0  226m  11m 3972 S    0  0.1   0:07.65 apache2
    10571 www-data  20   0  226m  10m 3724 S    0  0.1   0:04.49 apache2
    10620 www-data  20   0  226m  10m 3872 S    0  0.1   0:04.28 apache2
    10890 www-data  20   0  224m 8984 3636 S    0  0.1   0:04.78 apache2
    12476 www-data  20   0  226m  10m 3680 S    0  0.1   0:04.45 apache2
    12953 www-data  20   0  226m  10m 3632 S    0  0.1   0:03.39 apache2
    12960 www-data  20   0  224m 8852 3640 S    0  0.1   0:03.61 apache2
    13296 www-data  20   0  226m  10m 3860 S    0  0.1   0:16.18 apache2
    13301 www-data  20   0  226m  10m 3892 S    0  0.1   0:15.43 apache2
    13467 www-data  20   0  226m  10m 3772 S    0  0.1   0:16.87 apache2
    14174 www-data  20   0  226m  10m 3880 S    0  0.1   0:15.08 apache2
    14226 www-data  20   0  226m  10m 3872 S    0  0.1   0:15.53 apache2
    14367 www-data  20   0  224m 8724 3664 S    0  0.1   0:03.44 apache2
    14368 www-data  20   0  224m 8728 3648 S    0  0.1   0:03.49 apache2
    14438 www-data  20   0  226m  10m 3880 S    0  0.1   0:16.09 apache2
    ...
    EXPLAIN d'une requete de SELECT
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    EXPLAIN SELECT T_poster.id, T_poster.file, T_poster.dater, FC_ratings.hits, FC_ratings.total_votes,
    FC_name.name, FC_name.country, FC_name.id AS IDName
    FROM  FC_poster AS T_poster
    LEFT JOIN FC_name ON (T_poster.id_name = FC_name.id)
    LEFT JOIN FC_ratings ON (T_poster.id = FC_ratings.id)
    WHERE FC_name.born <= '01-01-1990'
    ORDER BY T_poster.dater DESC
    LIMIT  0,45
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    id	select_type	table	type	possible_keys	key		key_len	ref		rows	Extra
    1	SIMPLE	T_poster	index	id_name		dater	8	NULL			61200	 
    1	SIMPLE	FC_name		eq_ref	PRIMARY,born	PRIMARY	2	cfake.T_poster.id_name	1	Using where
    1	SIMPLE	FC_ratings	eq_ref	id		id	3	cfake.T_poster.id	1
    Et voilà le meme top au moment ou j'effectue UPDATE pour la 61201eme entrée :

    Tout monte en flèche, l'update et effectuer mais dans les secondes qui suivent,
    sur le site j'ai : Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '127.0.0.1' (4) in /home/cfake/connexion.php on line 2

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
     
    top - 17:42:29 up 12 days, 23:29,  1 user,  load average: 80.49, 26.09, 10.83
    Tasks: 944 total,   1 running, 943 sleeping,   0 stopped,   0 zombie
    Cpu(s):  3.1%us,  7.8%sy,  0.0%ni, 67.9%id, 21.0%wa,  0.1%hi,  0.0%si,  0.0%st
    Mem:   8091116k total,  8039968k used,    51148k free,     7972k buffers
    Swap:  2096472k total,   886092k used,  1210380k free,    35444k cached
     
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    18012 mysql     20   0 6086m 4.8g 2168 D  220 62.4   1033:06 mysqld
      402 root      15  -5     0    0    0 S   22  0.0  13:27.73 kswapd0
    24556 root      20   0 19640 1600  596 R    1  0.0   0:09.37 top
    30174 root      20   0  222m 2524  492 S    0  0.0   0:26.28 apache2
        1 root      20   0  4004   88   40 S    0  0.0   0:00.99 init
        2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd
        3 root      RT  -5     0    0    0 S    0  0.0   0:00.16 migration/0
        4 root      15  -5     0    0    0 S    0  0.0   0:00.95 ksoftirqd/0
        5 root      RT  -5     0    0    0 S    0  0.0   0:00.36 migration/1
        6 root      15  -5     0    0    0 S    0  0.0   0:14.10 ksoftirqd/1
        7 root      RT  -5     0    0    0 S    0  0.0   0:00.25 migration/2
        8 root      15  -5     0    0    0 S    0  0.0   0:10.77 ksoftirqd/2
        9 root      RT  -5     0    0    0 S    0  0.0   0:00.37 migration/3
       10 root      15  -5     0    0    0 S    0  0.0   0:08.35 ksoftirqd/3
       11 root      15  -5     0    0    0 S    0  0.0   0:00.10 events/0
       12 root      15  -5     0    0    0 S    0  0.0   0:03.19 events/1
    ...
    EXPLAIN d'une requete de SELECT
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    EXPLAIN SELECT T_poster.id, T_poster.file, T_poster.dater, FC_ratings.hits, FC_ratings.total_votes,
    FC_name.name, FC_name.country, FC_name.id AS IDName
    FROM  FC_poster AS T_poster
    LEFT JOIN FC_name ON (T_poster.id_name = FC_name.id)
    LEFT JOIN FC_ratings ON (T_poster.id = FC_ratings.id)
    WHERE FC_name.born <= '01-01-1990'
    ORDER BY T_poster.dater DESC
    LIMIT  0,45
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    id	select_type	table		type		possible_keys	key	key_len	ref		rows	Extra
    1	SIMPLE		FC_name	ALL	PRIMARY,born	NULL		NULL	NULL			3074	Using where; Using temporary; Using filesort
    1	SIMPLE		T_poster	ref	id_name	id_name		2	cfake.FC_name.id	20	 
    1	SIMPLE		FC_ratings	eq_ref	id	id		3	cfake.T_poster.id	1

    A ce moment je stop les serveurs mysql, apache2
    Puis je start les serveurs, je supprime rapidement (avant une re saturation) l'entrée et tout revient à la normale.


    Question espace disque, je pense pas avoir de probleme :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    df -h
    Sys. de fich.            Tail. Occ. Disp. %Occ. Monté sur
    /dev/sda1             9,7G  2,9G  6,3G  32% /
    varrun                3,9G   72K  3,9G   1% /var/run
    varlock               3,9G     0  3,9G   0% /var/lock
    udev                  3,9G   20K  3,9G   1% /dev
    devshm                3,9G     0  3,9G   0% /dev/shm
    /dev/sda2             677G   43G  600G   7% /home

    Pour information voilà "sh tuning-primer.sh" apres 21h de Uptime
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
     
    mysqld is alive
     
            -- MYSQL PERFORMANCE TUNING PRIMER --
                 - By: Matthew Montgomery -
     
    MySQL Version 5.0.51a-3ubuntu5.4-log x86_64
     
    Uptime = 0 days 21 hrs 59 min 55 sec
    Avg. qps = 334
    Total Questions = 26455813
    Threads Connected = 11
     
    Warning: Server has not been running for at least 48hrs.
    It may not be safe to use these recommendations
     
    To find out more information on how each of these
    runtime variables effects performance visit:
    http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL's Enterprise Monitoring and Advisory Service
     
    SLOW QUERIES
    The slow query log is enabled.
    Current long_query_time = 3 sec.
    You have 70 out of 26455834 that take longer than 3 sec. to complete
    Your long_query_time seems to be fine
     
    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html
     
    WORKER THREADS
    Current thread_cache_size = 32
    Current threads_cached = 16
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
     
    MAX CONNECTIONS
    Current max_connections = 500
    Current threads_connected = 18
    Historic max_used_connections = 132
    The number of used connections is 26% of the configured maximum.
    Your max_connections variable seems to be fine.
     
    MEMORY USAGE
    Max Memory Ever Allocated : 1 G
    Configured Max Per-thread Buffers : 1 G
    Configured Max Global Buffers : 1 G
    Configured Max Memory Limit : 2 G
    Physical Memory : 7.71 G
    Max memory limit seem to be within acceptable norms
     
    KEY BUFFER
    Current MyISAM index space = 12 M
    Current key_buffer_size = 8 M
    Key cache miss rate is 1 : 2257438
    Key buffer fill ratio = 54.00 %
    Your key_buffer_size seems to be too high.
    Perhaps you can use these resources elsewhere
     
    QUERY CACHE
    Query cache is enabled
    Current query_cache_size = 1.00 G
    Current query_cache_used = 891 M
    Current query_cache_limit = 32 M
    Current Query cache Memory fill ratio = 87.02 %
    Current query_cache_min_res_unit = 4 K
    However, 388445 queries have been removed from the query cache due to lack of memory
    Perhaps you should raise query_cache_size
    MySQL won't cache query results that are larger than query_cache_limit in size
     
    SORT OPERATIONS
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 256 K
    Sort buffer seems to be fine
     
    JOINS
    Current join_buffer_size = 132.00 K
    You have had 0 queries where a join could not use an index properly
    Your joins seem to be using indexes properly
     
    OPEN FILES LIMIT
    Current open_files_limit = 2910 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine
     
    TABLE CACHE
    Current table_cache value = 1200 tables
    You have a total of 79 tables
    You have 326 open tables.
    The table_cache value seems to be fine
     
    TEMP TABLES
    Current max_heap_table_size = 512 M
    Current tmp_table_size = 512 M
    Of 304075 temp tables, 0% were created on disk
    Created disk tmp tables ratio seems fine
     
    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 255 : 1
    read_buffer_size seems to be fine
     
    TABLE LOCKING
    Current Lock Wait ratio = 1 : 52
    You may benefit from selective use of InnoDB.
    Si, besoin de toutes autres informations c'est possible.

Discussions similaires

  1. Réponses: 2
    Dernier message: 24/11/2005, 22h30
  2. [SQL] pb de modification d'une entrée de ma bd
    Par auryn111 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 09/09/2005, 10h54
  3. modifier le bouton parcourir en image d'une entré texte
    Par Death83 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 04/09/2005, 22h49
  4. modélisation d'une base : table trop grande
    Par Shabata dans le forum Décisions SGBD
    Réponses: 2
    Dernier message: 22/11/2004, 11h44
  5. [sdl+glut] une console en trop
    Par khayyam90 dans le forum GLUT
    Réponses: 3
    Dernier message: 02/08/2004, 09h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo