SlideShare a Scribd company logo
POST GRESQL – M YSQL
INST RU CT OR: EM A NU EL CA LVO
Tips de monitoreo con SQL
C O NC EPT O S B Á SIC O S
Premisas
Premisas
 Evitar/monitorear la latencia de escritura y lectura.
 Es lo que tardan los dispositivos de almacenamiento, en
devolver los datos.
 Aumentar/monitorear el rendimiento de salida de
resultados.
 Capacidad de respuesta del servidor.
 Seguridad.
Bases de datos veloces,
implican aplicaciones
Veloces.
Como lograr …?
 Menor latencia de I/O:
 Más discos.
 Discos más rápidos.
 Tablespaces y particiones separadas entre si.
 Utilización de sistemas de ficheros más avanzados.
 Rendimiento:
 Más memoria.
 Más y mejores procesadores y núcleos.
 Mejor conexión entre servidores en red.
 Servidores dedicados.
Monitoreo Básico
 Desde el Sistema Operativo.
 Se obtiene el rendimiento en términos específicos del sistema
operativo y hardware.
 Desde el motor de Base de datos.
 Se puede obtener datos de accesos a objetos y cantidad de datos en
caché de los mismos.
Monitoreo de Base
 Estado de los accesos a relaciones.
 Estado de las estadísticas.
 Estados de los índices.
 Estado del caché.
 Procesos en ejecución.
 TPS con pgbench, medir rendimiento.
 Consultas lentas.
Postgresql Mysql
 Select
pg_size_pretty(pg_dat
abase_size(name));
 SELECT
pg_size_pretty(pg_tot
al_relation_size(tabla)
);
 SELECT table_schema "Data Base
Name", sum( data_length +
index_length ) / 1024 / 1024 "Data
Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
 SELECT table_schema "Data Base
Name",
sum( data_length + index_length ) /
1024 /
1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free
Space in MB"
FROM
information_schema.TABLES
GROUP BY table_schema ;
Tamaño de la base y tablas
Postgresql Mysql
 SELECT
pg_size_pretty(pg_tot
al_relation_size(tabla)
);
 SELECT
pg_size_pretty(pg_rela
tion_size(tabla));
 SELECT table_name,
table_rows, data_length,
index_length,
round(((data_length +
index_length) / 1024 /
1024),2) "Size in MB"
FROM
information_schema.TA
BLES WHERE
table_schema =
"schema_name";
Tamaño tablas
Postgresql Mysql
 SELECT * FROM
pg_stat_activity;
 SHOW PROCESSLIST;
 SHOW STATUS LIKE
'%threads%';
 show session status like
'connections';
Procesos
A PA RT A D O D E C O NSU LT A S PA RA M YSQ L
Mysql
Engines (Mysql)
 Show engines;
 show engine innodb status;
InnoDB Status
Per second averages calculated from the last 59 seconds
-----------------BACKGROUND THREAD-----------------
srv_master_thread loops: 4 1_second, 0 sleeps, 0 10_second, 5 background, 5 flush
srv_master_thread log flush and writes: 0
----------SEMAPHORES----------
OS WAIT ARRAY INFO: reservation count 3, signal count 3
Mutex spin waits 1, rounds 30, OS waits 0
RW-shared spins 3, rounds 90, OS waits 3
RW-excl spins 0, rounds 0, OS waits 0
Spin rounds per wait: 30.00 mutex, 30.00 RW-shared, 0.00 RW-excl
------------TRANSACTIONS------------
Trx id counter 502
Purge done for trx's n:o < 32C undo n:o < 0
History list length 7
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started, OS thread id 2988
MySQL thread id 6, query id 110 localhost 127.0.0.1 root
show engine innodb status
---TRANSACTION 501, not started, OS thread id 3568
MySQL thread id 4, query id 105 localhost 127.0.0.1 root
---TRANSACTION 0, not started, OS thread id 3552
MySQL thread id 2, query id 59 localhost 127.0.0.1 root
--------FILE I/O--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: wait Windows aio (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
191 OS file reads, 7 OS file writes, 7 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
--------------------INSERT BUFFER AND ADAPTIVE HASH INDEX-------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 195193, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---LOG---
Log sequence number 3308699
Log flushed up to 3308699
Last checkpoint at 3308699
0 pending log writes, 0 pending chkp writes
10 log i/o's done, 0.00 log i/o's/second
---------BUFFER POOL AND MEMORY----------------------
Total memory allocated 49971200; in additional pool allocated 0
Dictionary memory allocated 18671
Buffer pool size 3008
Free buffers 2829
Database pages 179
Old database pages 0
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 179, created 0, written 1
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s
LRU len: 179, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------ROW OPERATION------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 796, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 11
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Explorando tablas
mysql> select * from
information_schema.tables
where TABLE_NAME like 'prueba' limit
1G
******* 1. row *****************
TABLE_CATALOG: def
TABLE_SCHEMA: mysql
TABLE_NAME: prueba
TABLE_TYPE: BASE TABLE
ENGINE: InnoDB
VERSION: 10
ROW_FORMAT: Compact
TABLE_ROWS: 5
AVG_ROW_LENGTH: 3276
DATA_LENGTH: 16384
MAX_DATA_LENGTH: 0
INDEX_LENGTH: 0
DATA_FREE: 0
AUTO_INCREMENT: 6
CREATE_TIME: 2010-11-
03 12:09:45
UPDATE_TIME: NULL
CHECK_TIME: NULL
TABLE_COLLATION:
latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
1 row in set (0.00 sec)
Explarando Tablas (2)
 show table status from
mysql like 'prueba'G
Particiones
mysql> select * from
information_schame.partitions where
table_name = 'prueba' limit 1G
********** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: mysql
TABLE_NAME: prueba
PARTITION_NAME: NULL
SUBPARTITION_NAME: NULL
PARTITION_ORDINAL_POSITION: NULL
SUBPARTITION_ORDINAL_POSITION: NULL
PARTITION_METHOD: NULL
SUBPARTITION_METHOD: NULL
PARTITION_EXPRESSION: NULL
SUBPARTITION_EXPRESSION: NULL
PARTITION_DESCRIPTION: NULL
TABLE_ROWS: 5
AVG_ROW_LENGTH: 3276
DATA_LENGTH: 16384
MAX_DATA_LENGTH: NULL
INDEX_LENGTH: 0
DATA_FREE: 0
CREATE_TIME: 2010-11-03 12:09:45
UPDATE_TIME: NULL
CHECK_TIME: NULL
CHECKSUM: NULL
PARTITION_COMMENT:
NODEGROUP:
TABLESPACE_NAME: NULL
1 row in set (0.02 sec)
Estadísticas
mysql> select * from statistics
where table_name like 'prueba' limit 1G
********* 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: mysql
TABLE_NAME: prueba
NON_UNIQUE: 0
INDEX_SCHEMA: mysql
INDEX_NAME: PRIMARY
SEQ_IN_INDEX: 1
COLUMN_NAME: the_key
COLLATION: A
CARDINALITY: 5
SUB_PART: NULL
PACKED: NULL
NULLABLE:
INDEX_TYPE: BTREE
COMMENT:
INDEX_COMMENT:
1 row in set (0.02 sec)
Working example
mysql> show table status like 'prueba'G
Name: prueba
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 9703
Avg_row_length: 35
Data_length: 344064
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: 16371
Create_time: 2010-11-03 12:09:45
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
mysql> delete from prueba where a between
80 and 81; Query OK, 218 rows affected (0.30
sec)
mysql> show table status like 'prueba'G
Name: prueba
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 10823
Avg_row_length: 31
Data_length: 344064
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: 16371
Create_time: 2010-11-03 12:09:45
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Working example (2)
mysql> optimize table pruebaG
1. row ***************************
Table: mysql.prueba
Op: optimize
Msg_type: note
Msg_text: Table does not support
optimize, doing recreate + analyze
instead
2. row ***************************
Table: mysql.prueba
Op: optimize
Msg_type: status
Msg_text: OK
2 rows in set (2.13 sec)
mysql> show table status like 'prueba'G
1. row ***************************
Name: prueba
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 10508
Avg_row_length: 31
Data_length: 327680
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: 13300
Create_time: 2010-11-03 12:09:45
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
A PA RT A D O C O NSU LT A S PA RA PO ST GRESQ L
Postgresql
Monitoreo de Base
 Estado de los accesos a relaciones.
 Pg_statio_user_tables
 Pg_stat_user_tables
 Tamaños
 select pg_size_pretty( pg_database_size(‘ejemplo'));
 select pg_size_pretty( pg_relation_size('datos'::regclass));
Monitoreo de Base
 Estado de las estadísticas.
 Pg_stats
 SELECT * FROM pg_stats WHERE tablename = ‘tabla’ AND
attname = ‘columna’;
Monitoreo de Base
 Estados de los índices.
 Pg_stat_user_indexes
 Pg_statio_user_indexes
Monitoreo de Base
 Estado del caché.
 Cantidad de bloques leídos:
 Select pg_stat_get_db_blocks_fetched((select datid from
pg_stat_database where datname = 'pampabs'));
 Bloques leídos y en caché:
 Select pg_stat_get_db_blocks_hit((select datid from
pg_stat_database where datname = 'pampabs'));
Postgresql Mysql
 Consultas lentas.
 Activar
log_min_duration_state
ment (milisegundos).
 Consultas lentas
 log_slow_queries
 log_queries_not_using_i
ndexes
Consultas lentas
Trucos
 Realizando un ALTER TABLE sin modificar la tabla
se obliga la reestructuración.
 Ordenar los registros físicamente:
 SELECT * INTO tabla2 FROM tabla ORDER BY columna;
A LGU NOS CONT RIB S PA RA M ONIT OREO
Contribs Postgresql
pg_stat_statements
 Loguea absolutamente
todas las consultas.
 Funciones:
 pg_stat_statements_reset
()
 Se utiliza:
 Select * from
pg_stat_statements;
#Configuracion en el Postgresql.conf:
shared_preload_libraries='pg_stat_state
ments'
custom_variable_classes='pg_stat_state
ments'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
pg_stat_statements.save = on
pgfouine
 Descargar desde
pgfoundry.org.
 Necesita un php-cli.
 Si tenemos que usar
stderr, el log_line_prefix
debe establecerse en:
 ‘%t [%p]: [%l-1]’
Php pgfouine.php -format html-
with-graphics –logtype stderr –
file <archivo_log> >
result.html
pgstattuple
 Varias funciones de
medición estadística.
 Solo hacen un bloqueo de
lectura.
 pgstattuple(‘table’)
 pgstatindex(‘index’)
 pg_relpages
pgrowlocks
 Devuelve la información
por tupla.
 Devuelve lock_type.
SELECT *
FROM
general g JOIN
pgrowlocks(‘general’) p
ON (g.ctid = p.locked_row);
Gracias Por asistir
Esta presentación está
bajo licencia GPL.
Contacte a: postgres.arg
(at) gmail.com
Skype: emanuel.cfranco

More Related Content

What's hot

Firewall(linux)
Firewall(linux)Firewall(linux)
Firewall(linux)
Santosh Khadsare
 
10 File System
10 File System10 File System
10 File System
Dr. Loganathan R
 
Approach to heart failure cases
Approach to heart failure casesApproach to heart failure cases
Approach to heart failure cases
hospital
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
Anil Kumar Pugalia
 
Kardiorenal sendromlarıingilizcesunum
Kardiorenal sendromlarıingilizcesunumKardiorenal sendromlarıingilizcesunum
Kardiorenal sendromlarıingilizcesunum
tyfngnc
 
Views on building blocks
Views on building blocksViews on building blocks
Views on building blocks
Ritesh Khanna
 
4 threads
4 threads4 threads
4 threads
Dr. Loganathan R
 
Лекція №4
Лекція №4Лекція №4
Лекція №4
Michael Attwood
 
cpu scheduling in os
cpu scheduling in oscpu scheduling in os
cpu scheduling in os
Kiran Kumar Thota
 
Less07 storage
Less07 storageLess07 storage
Less07 storage
Amit Bhalla
 
Database software
Database softwareDatabase software
Database software
JahidHussain13
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
Prof. Dr. K. Adisesha
 
Windows Operating system
Windows Operating systemWindows Operating system
Windows Operating system
Shami Al Rahad
 
Dbms tutorial
Dbms tutorialDbms tutorial
Dbms tutorial
ankindian
 
Ch1
Ch1Ch1
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
Janki Shah
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
rizwanaabassi
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systems
Viet-Trung TRAN
 
Chapter 4 - Threads
Chapter 4 - ThreadsChapter 4 - Threads
Chapter 4 - Threads
Wayne Jones Jnr
 

What's hot (20)

Firewall(linux)
Firewall(linux)Firewall(linux)
Firewall(linux)
 
10 File System
10 File System10 File System
10 File System
 
Approach to heart failure cases
Approach to heart failure casesApproach to heart failure cases
Approach to heart failure cases
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
Kardiorenal sendromlarıingilizcesunum
Kardiorenal sendromlarıingilizcesunumKardiorenal sendromlarıingilizcesunum
Kardiorenal sendromlarıingilizcesunum
 
Views on building blocks
Views on building blocksViews on building blocks
Views on building blocks
 
4 threads
4 threads4 threads
4 threads
 
Лекція №4
Лекція №4Лекція №4
Лекція №4
 
cpu scheduling in os
cpu scheduling in oscpu scheduling in os
cpu scheduling in os
 
Less07 storage
Less07 storageLess07 storage
Less07 storage
 
Database software
Database softwareDatabase software
Database software
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Windows Operating system
Windows Operating systemWindows Operating system
Windows Operating system
 
Dbms tutorial
Dbms tutorialDbms tutorial
Dbms tutorial
 
Ch1
Ch1Ch1
Ch1
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systems
 
Chapter 4 - Threads
Chapter 4 - ThreadsChapter 4 - Threads
Chapter 4 - Threads
 

Similar to Monitoreo de MySQL y PostgreSQL con SQL

Thomas+Niewel+ +Oracletuning
Thomas+Niewel+ +OracletuningThomas+Niewel+ +Oracletuning
Thomas+Niewel+ +Oracletuning
afa reg
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
Ligaya Turmelle
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMX
zznate
 
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
DataStax
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
Manish Rawat
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
Command Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
Mark Wong
 
Using AWR for IO Subsystem Analysis
Using AWR for IO Subsystem AnalysisUsing AWR for IO Subsystem Analysis
Using AWR for IO Subsystem Analysis
Texas Memory Systems, and IBM Company
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
iammutex
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL Server
Stephen Rose
 
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesMySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
Severalnines
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
Amazon Web Services
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)
akirahiguchi
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
Kyle Hailey
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
Kyle Hailey
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
Nathan Winters
 
Operation outbreak
Operation outbreakOperation outbreak
Operation outbreak
Prathan Phongthiproek
 
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User ConferenceMySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
Severalnines
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчик
Agnislav Onufrijchuk
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton inserts
Chris Adkin
 

Similar to Monitoreo de MySQL y PostgreSQL con SQL (20)

Thomas+Niewel+ +Oracletuning
Thomas+Niewel+ +OracletuningThomas+Niewel+ +Oracletuning
Thomas+Niewel+ +Oracletuning
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMX
 
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
Advanced Cassandra Operations via JMX (Nate McCall, The Last Pickle) | C* Sum...
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Using AWR for IO Subsystem Analysis
Using AWR for IO Subsystem AnalysisUsing AWR for IO Subsystem Analysis
Using AWR for IO Subsystem Analysis
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL Server
 
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesMySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
Operation outbreak
Operation outbreakOperation outbreak
Operation outbreak
 
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User ConferenceMySQL Cluster Performance Tuning - 2013 MySQL User Conference
MySQL Cluster Performance Tuning - 2013 MySQL User Conference
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчик
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton inserts
 

More from Emanuel Calvo

Open Source SQL Databases
Open Source SQL DatabasesOpen Source SQL Databases
Open Source SQL Databases
Emanuel Calvo
 
Demystifying postgres logical replication percona live sc
Demystifying postgres logical replication percona live scDemystifying postgres logical replication percona live sc
Demystifying postgres logical replication percona live sc
Emanuel Calvo
 
Pgbr 2013 fts
Pgbr 2013 ftsPgbr 2013 fts
Pgbr 2013 fts
Emanuel Calvo
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on aws
Emanuel Calvo
 
PostgreSQL and Sphinx pgcon 2013
PostgreSQL and Sphinx   pgcon 2013PostgreSQL and Sphinx   pgcon 2013
PostgreSQL and Sphinx pgcon 2013
Emanuel Calvo
 
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAYPostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
Emanuel Calvo
 
LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)
Emanuel Calvo
 
Admon PG 1
Admon PG 1Admon PG 1
Admon PG 1
Emanuel Calvo
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
Emanuel Calvo
 

More from Emanuel Calvo (9)

Open Source SQL Databases
Open Source SQL DatabasesOpen Source SQL Databases
Open Source SQL Databases
 
Demystifying postgres logical replication percona live sc
Demystifying postgres logical replication percona live scDemystifying postgres logical replication percona live sc
Demystifying postgres logical replication percona live sc
 
Pgbr 2013 fts
Pgbr 2013 ftsPgbr 2013 fts
Pgbr 2013 fts
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on aws
 
PostgreSQL and Sphinx pgcon 2013
PostgreSQL and Sphinx   pgcon 2013PostgreSQL and Sphinx   pgcon 2013
PostgreSQL and Sphinx pgcon 2013
 
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAYPostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
 
LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)
 
Admon PG 1
Admon PG 1Admon PG 1
Admon PG 1
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 

Recently uploaded

"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
Indian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for StartupsIndian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for Startups
AMol NAik
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
jorgelebrato
 
TrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
TrustArc Webinar - Innovating with TRUSTe Responsible AI CertificationTrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
TrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
TrustArc
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Alliance
 
What's New in Copilot for Microsoft 365 June 2024.pptx
What's New in Copilot for Microsoft 365 June 2024.pptxWhat's New in Copilot for Microsoft 365 June 2024.pptx
What's New in Copilot for Microsoft 365 June 2024.pptx
Stephanie Beckett
 
Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024
Michael Price
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
Keynote : Presentation on SASE Technology
Keynote : Presentation on SASE TechnologyKeynote : Presentation on SASE Technology
Keynote : Presentation on SASE Technology
Priyanka Aash
 
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptxFIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Alliance
 
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptxFIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Alliance
 
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
Snarky Security
 
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Zilliz
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
Bhajan Mehta
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
Razin Mustafiz
 
FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptxFIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Alliance
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
siddu769252
 
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan..."Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
Fwdays
 
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptxFIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Alliance
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Alliance
 

Recently uploaded (20)

"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
 
Indian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for StartupsIndian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for Startups
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
 
TrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
TrustArc Webinar - Innovating with TRUSTe Responsible AI CertificationTrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
TrustArc Webinar - Innovating with TRUSTe Responsible AI Certification
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
 
What's New in Copilot for Microsoft 365 June 2024.pptx
What's New in Copilot for Microsoft 365 June 2024.pptxWhat's New in Copilot for Microsoft 365 June 2024.pptx
What's New in Copilot for Microsoft 365 June 2024.pptx
 
Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
Keynote : Presentation on SASE Technology
Keynote : Presentation on SASE TechnologyKeynote : Presentation on SASE Technology
Keynote : Presentation on SASE Technology
 
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptxFIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptx
 
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptxFIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
 
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...
 
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
Garbage In, Garbage Out: Why poor data curation is killing your AI models (an...
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
 
FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptxFIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptx
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
 
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan..."Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
"Building Future-Ready Apps with .NET 8 and Azure Serverless Ecosystem", Stan...
 
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptxFIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
 

Monitoreo de MySQL y PostgreSQL con SQL

  • 1. POST GRESQL – M YSQL INST RU CT OR: EM A NU EL CA LVO Tips de monitoreo con SQL
  • 2. C O NC EPT O S B Á SIC O S Premisas
  • 3. Premisas  Evitar/monitorear la latencia de escritura y lectura.  Es lo que tardan los dispositivos de almacenamiento, en devolver los datos.  Aumentar/monitorear el rendimiento de salida de resultados.  Capacidad de respuesta del servidor.  Seguridad. Bases de datos veloces, implican aplicaciones Veloces.
  • 4. Como lograr …?  Menor latencia de I/O:  Más discos.  Discos más rápidos.  Tablespaces y particiones separadas entre si.  Utilización de sistemas de ficheros más avanzados.  Rendimiento:  Más memoria.  Más y mejores procesadores y núcleos.  Mejor conexión entre servidores en red.  Servidores dedicados.
  • 5. Monitoreo Básico  Desde el Sistema Operativo.  Se obtiene el rendimiento en términos específicos del sistema operativo y hardware.  Desde el motor de Base de datos.  Se puede obtener datos de accesos a objetos y cantidad de datos en caché de los mismos.
  • 6. Monitoreo de Base  Estado de los accesos a relaciones.  Estado de las estadísticas.  Estados de los índices.  Estado del caché.  Procesos en ejecución.  TPS con pgbench, medir rendimiento.  Consultas lentas.
  • 7. Postgresql Mysql  Select pg_size_pretty(pg_dat abase_size(name));  SELECT pg_size_pretty(pg_tot al_relation_size(tabla) );  SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;  SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema ; Tamaño de la base y tablas
  • 8. Postgresql Mysql  SELECT pg_size_pretty(pg_tot al_relation_size(tabla) );  SELECT pg_size_pretty(pg_rela tion_size(tabla));  SELECT table_name, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TA BLES WHERE table_schema = "schema_name"; Tamaño tablas
  • 9. Postgresql Mysql  SELECT * FROM pg_stat_activity;  SHOW PROCESSLIST;  SHOW STATUS LIKE '%threads%';  show session status like 'connections'; Procesos
  • 10. A PA RT A D O D E C O NSU LT A S PA RA M YSQ L Mysql
  • 11. Engines (Mysql)  Show engines;  show engine innodb status;
  • 12. InnoDB Status Per second averages calculated from the last 59 seconds -----------------BACKGROUND THREAD----------------- srv_master_thread loops: 4 1_second, 0 sleeps, 0 10_second, 5 background, 5 flush srv_master_thread log flush and writes: 0 ----------SEMAPHORES---------- OS WAIT ARRAY INFO: reservation count 3, signal count 3 Mutex spin waits 1, rounds 30, OS waits 0 RW-shared spins 3, rounds 90, OS waits 3 RW-excl spins 0, rounds 0, OS waits 0 Spin rounds per wait: 30.00 mutex, 30.00 RW-shared, 0.00 RW-excl ------------TRANSACTIONS------------ Trx id counter 502 Purge done for trx's n:o < 32C undo n:o < 0 History list length 7 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 0, not started, OS thread id 2988 MySQL thread id 6, query id 110 localhost 127.0.0.1 root show engine innodb status ---TRANSACTION 501, not started, OS thread id 3568 MySQL thread id 4, query id 105 localhost 127.0.0.1 root ---TRANSACTION 0, not started, OS thread id 3552 MySQL thread id 2, query id 59 localhost 127.0.0.1 root --------FILE I/O-------- I/O thread 0 state: wait Windows aio (insert buffer thread) I/O thread 1 state: wait Windows aio (log thread) I/O thread 2 state: wait Windows aio (read thread) I/O thread 3 state: wait Windows aio (read thread) I/O thread 4 state: wait Windows aio (read thread) I/O thread 5 state: wait Windows aio (read thread) I/O thread 6 state: wait Windows aio (write thread) I/O thread 7 state: wait Windows aio (write thread) I/O thread 8 state: wait Windows aio (write thread) I/O thread 9 state: wait Windows aio (write thread) Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] , ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 191 OS file reads, 7 OS file writes, 7 OS fsyncs 0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s --------------------INSERT BUFFER AND ADAPTIVE HASH INDEX------------------- Ibuf: size 1, free list len 0, seg size 2, 0 merges merged operations: insert 0, delete mark 0, delete 0 discarded operations: insert 0, delete mark 0, delete 0 Hash table size 195193, node heap has 0 buffer(s) 0.00 hash searches/s, 0.00 non-hash searches/s ---LOG--- Log sequence number 3308699 Log flushed up to 3308699 Last checkpoint at 3308699 0 pending log writes, 0 pending chkp writes 10 log i/o's done, 0.00 log i/o's/second ---------BUFFER POOL AND MEMORY---------------------- Total memory allocated 49971200; in additional pool allocated 0 Dictionary memory allocated 18671 Buffer pool size 3008 Free buffers 2829 Database pages 179 Old database pages 0 Modified db pages 0 Pending reads 0 Pending writes: LRU 0, flush list 0, single page 0 Pages made young 0, not young 0 0.00 youngs/s, 0.00 non-youngs/s Pages read 179, created 0, written 1 0.00 reads/s, 0.00 creates/s, 0.00 writes/s No buffer pool page gets since the last printout Pages read ahead 0.00/s, evicted without access 0.00/s LRU len: 179, unzip_LRU len: 0 I/O sum[0]:cur[0], unzip sum[0]:cur[0] ----------ROW OPERATION------------ 0 queries inside InnoDB, 0 queries in queue 1 read views open inside InnoDB Main thread id 796, state: waiting for server activity Number of rows inserted 0, updated 0, deleted 0, read 11 0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
  • 13. Explorando tablas mysql> select * from information_schema.tables where TABLE_NAME like 'prueba' limit 1G ******* 1. row ***************** TABLE_CATALOG: def TABLE_SCHEMA: mysql TABLE_NAME: prueba TABLE_TYPE: BASE TABLE ENGINE: InnoDB VERSION: 10 ROW_FORMAT: Compact TABLE_ROWS: 5 AVG_ROW_LENGTH: 3276 DATA_LENGTH: 16384 MAX_DATA_LENGTH: 0 INDEX_LENGTH: 0 DATA_FREE: 0 AUTO_INCREMENT: 6 CREATE_TIME: 2010-11- 03 12:09:45 UPDATE_TIME: NULL CHECK_TIME: NULL TABLE_COLLATION: latin1_swedish_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: 1 row in set (0.00 sec)
  • 14. Explarando Tablas (2)  show table status from mysql like 'prueba'G
  • 15. Particiones mysql> select * from information_schame.partitions where table_name = 'prueba' limit 1G ********** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: mysql TABLE_NAME: prueba PARTITION_NAME: NULL SUBPARTITION_NAME: NULL PARTITION_ORDINAL_POSITION: NULL SUBPARTITION_ORDINAL_POSITION: NULL PARTITION_METHOD: NULL SUBPARTITION_METHOD: NULL PARTITION_EXPRESSION: NULL SUBPARTITION_EXPRESSION: NULL PARTITION_DESCRIPTION: NULL TABLE_ROWS: 5 AVG_ROW_LENGTH: 3276 DATA_LENGTH: 16384 MAX_DATA_LENGTH: NULL INDEX_LENGTH: 0 DATA_FREE: 0 CREATE_TIME: 2010-11-03 12:09:45 UPDATE_TIME: NULL CHECK_TIME: NULL CHECKSUM: NULL PARTITION_COMMENT: NODEGROUP: TABLESPACE_NAME: NULL 1 row in set (0.02 sec)
  • 16. Estadísticas mysql> select * from statistics where table_name like 'prueba' limit 1G ********* 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: mysql TABLE_NAME: prueba NON_UNIQUE: 0 INDEX_SCHEMA: mysql INDEX_NAME: PRIMARY SEQ_IN_INDEX: 1 COLUMN_NAME: the_key COLLATION: A CARDINALITY: 5 SUB_PART: NULL PACKED: NULL NULLABLE: INDEX_TYPE: BTREE COMMENT: INDEX_COMMENT: 1 row in set (0.02 sec)
  • 17. Working example mysql> show table status like 'prueba'G Name: prueba Engine: InnoDB Version: 10 Row_format: Compact Rows: 9703 Avg_row_length: 35 Data_length: 344064 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: 16371 Create_time: 2010-11-03 12:09:45 Update_time: NULL Check_time: NULL Collation: latin1_swedish_ci Checksum: NULL mysql> delete from prueba where a between 80 and 81; Query OK, 218 rows affected (0.30 sec) mysql> show table status like 'prueba'G Name: prueba Engine: InnoDB Version: 10 Row_format: Compact Rows: 10823 Avg_row_length: 31 Data_length: 344064 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: 16371 Create_time: 2010-11-03 12:09:45 Update_time: NULL Check_time: NULL Collation: latin1_swedish_ci Checksum: NULL
  • 18. Working example (2) mysql> optimize table pruebaG 1. row *************************** Table: mysql.prueba Op: optimize Msg_type: note Msg_text: Table does not support optimize, doing recreate + analyze instead 2. row *************************** Table: mysql.prueba Op: optimize Msg_type: status Msg_text: OK 2 rows in set (2.13 sec) mysql> show table status like 'prueba'G 1. row *************************** Name: prueba Engine: InnoDB Version: 10 Row_format: Compact Rows: 10508 Avg_row_length: 31 Data_length: 327680 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: 13300 Create_time: 2010-11-03 12:09:45 Update_time: NULL Check_time: NULL Collation: latin1_swedish_ci Checksum: NULL Create_options:
  • 19. A PA RT A D O C O NSU LT A S PA RA PO ST GRESQ L Postgresql
  • 20. Monitoreo de Base  Estado de los accesos a relaciones.  Pg_statio_user_tables  Pg_stat_user_tables  Tamaños  select pg_size_pretty( pg_database_size(‘ejemplo'));  select pg_size_pretty( pg_relation_size('datos'::regclass));
  • 21. Monitoreo de Base  Estado de las estadísticas.  Pg_stats  SELECT * FROM pg_stats WHERE tablename = ‘tabla’ AND attname = ‘columna’;
  • 22. Monitoreo de Base  Estados de los índices.  Pg_stat_user_indexes  Pg_statio_user_indexes
  • 23. Monitoreo de Base  Estado del caché.  Cantidad de bloques leídos:  Select pg_stat_get_db_blocks_fetched((select datid from pg_stat_database where datname = 'pampabs'));  Bloques leídos y en caché:  Select pg_stat_get_db_blocks_hit((select datid from pg_stat_database where datname = 'pampabs'));
  • 24. Postgresql Mysql  Consultas lentas.  Activar log_min_duration_state ment (milisegundos).  Consultas lentas  log_slow_queries  log_queries_not_using_i ndexes Consultas lentas
  • 25. Trucos  Realizando un ALTER TABLE sin modificar la tabla se obliga la reestructuración.  Ordenar los registros físicamente:  SELECT * INTO tabla2 FROM tabla ORDER BY columna;
  • 26. A LGU NOS CONT RIB S PA RA M ONIT OREO Contribs Postgresql
  • 27. pg_stat_statements  Loguea absolutamente todas las consultas.  Funciones:  pg_stat_statements_reset ()  Se utiliza:  Select * from pg_stat_statements; #Configuracion en el Postgresql.conf: shared_preload_libraries='pg_stat_state ments' custom_variable_classes='pg_stat_state ments' pg_stat_statements.max = 10000 pg_stat_statements.track = all pg_stat_statements.save = on
  • 28. pgfouine  Descargar desde pgfoundry.org.  Necesita un php-cli.  Si tenemos que usar stderr, el log_line_prefix debe establecerse en:  ‘%t [%p]: [%l-1]’ Php pgfouine.php -format html- with-graphics –logtype stderr – file <archivo_log> > result.html
  • 29. pgstattuple  Varias funciones de medición estadística.  Solo hacen un bloqueo de lectura.  pgstattuple(‘table’)  pgstatindex(‘index’)  pg_relpages
  • 30. pgrowlocks  Devuelve la información por tupla.  Devuelve lock_type. SELECT * FROM general g JOIN pgrowlocks(‘general’) p ON (g.ctid = p.locked_row);
  • 31. Gracias Por asistir Esta presentación está bajo licencia GPL. Contacte a: postgres.arg (at) gmail.com Skype: emanuel.cfranco