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

Understanding das-nas-san
Understanding das-nas-sanUnderstanding das-nas-san
Understanding das-nas-sanAshwin Pawar
 
O que foi o Concílio Vaticano II
O que foi o Concílio Vaticano IIO que foi o Concílio Vaticano II
O que foi o Concílio Vaticano IIPedronobrega1
 
Teología de la predicación cristiana
Teología de la predicación cristianaTeología de la predicación cristiana
Teología de la predicación cristianaPablo A. Jimenez
 
Desarrollando Tu Fundamento Espiritual
Desarrollando Tu Fundamento EspiritualDesarrollando Tu Fundamento Espiritual
Desarrollando Tu Fundamento EspiritualCarolina Yang
 
El caracter que sustenta el ministerio
El caracter que sustenta el ministerioEl caracter que sustenta el ministerio
El caracter que sustenta el ministerioJorge Chavez
 
Cloud Computing Architecture
Cloud Computing Architecture Cloud Computing Architecture
Cloud Computing Architecture Vasu Jain
 
Difference between net app 7 mode and netapp cluster mode
Difference between net app 7 mode and netapp cluster modeDifference between net app 7 mode and netapp cluster mode
Difference between net app 7 mode and netapp cluster modeVidhyalive
 
Création de visuels personnalisés avec Power BI Visuals CLI
Création de visuels personnalisés avec Power BI Visuals CLICréation de visuels personnalisés avec Power BI Visuals CLI
Création de visuels personnalisés avec Power BI Visuals CLIDenys Chamberland
 
What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...Shashi soni
 
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMHypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMvwchu
 
01 Historia de la Iglesia I milenio
01 Historia de la Iglesia I milenio01 Historia de la Iglesia I milenio
01 Historia de la Iglesia I mileniohistoriadelaiglesia
 
Ceph Intro and Architectural Overview by Ross Turk
Ceph Intro and Architectural Overview by Ross TurkCeph Intro and Architectural Overview by Ross Turk
Ceph Intro and Architectural Overview by Ross Turkbuildacloud
 
¿Que es un acceso remoto?
¿Que es un acceso remoto?¿Que es un acceso remoto?
¿Que es un acceso remoto?Javier Cortes
 
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...xKinAnx
 
كيف تقرأ الأيقونه او الصوره القبطيه؟
كيف تقرأ الأيقونه او الصوره القبطيه؟كيف تقرأ الأيقونه او الصوره القبطيه؟
كيف تقرأ الأيقونه او الصوره القبطيه؟MosaadRamadan AbdAlhk
 
Storage Virtualization
Storage VirtualizationStorage Virtualization
Storage VirtualizationMehul Jariwala
 

What's hot (20)

Understanding das-nas-san
Understanding das-nas-sanUnderstanding das-nas-san
Understanding das-nas-san
 
O que foi o Concílio Vaticano II
O que foi o Concílio Vaticano IIO que foi o Concílio Vaticano II
O que foi o Concílio Vaticano II
 
Teología de la predicación cristiana
Teología de la predicación cristianaTeología de la predicación cristiana
Teología de la predicación cristiana
 
Desarrollando Tu Fundamento Espiritual
Desarrollando Tu Fundamento EspiritualDesarrollando Tu Fundamento Espiritual
Desarrollando Tu Fundamento Espiritual
 
El caracter que sustenta el ministerio
El caracter que sustenta el ministerioEl caracter que sustenta el ministerio
El caracter que sustenta el ministerio
 
Cloud Computing Architecture
Cloud Computing Architecture Cloud Computing Architecture
Cloud Computing Architecture
 
Difference between net app 7 mode and netapp cluster mode
Difference between net app 7 mode and netapp cluster modeDifference between net app 7 mode and netapp cluster mode
Difference between net app 7 mode and netapp cluster mode
 
Création de visuels personnalisés avec Power BI Visuals CLI
Création de visuels personnalisés avec Power BI Visuals CLICréation de visuels personnalisés avec Power BI Visuals CLI
Création de visuels personnalisés avec Power BI Visuals CLI
 
What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...
 
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVMHypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
Hypervisors and Virtualization - VMware, Hyper-V, XenServer, and KVM
 
01 Historia de la Iglesia I milenio
01 Historia de la Iglesia I milenio01 Historia de la Iglesia I milenio
01 Historia de la Iglesia I milenio
 
Ceph Intro and Architectural Overview by Ross Turk
Ceph Intro and Architectural Overview by Ross TurkCeph Intro and Architectural Overview by Ross Turk
Ceph Intro and Architectural Overview by Ross Turk
 
¿Que es un acceso remoto?
¿Que es un acceso remoto?¿Que es un acceso remoto?
¿Que es un acceso remoto?
 
Hinduismo a la luz de la Biblia
Hinduismo a la luz de la BibliaHinduismo a la luz de la Biblia
Hinduismo a la luz de la Biblia
 
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
 
كيف تقرأ الأيقونه او الصوره القبطيه؟
كيف تقرأ الأيقونه او الصوره القبطيه؟كيف تقرأ الأيقونه او الصوره القبطيه؟
كيف تقرأ الأيقونه او الصوره القبطيه؟
 
RAID
RAIDRAID
RAID
 
La reforma
La reformaLa reforma
La reforma
 
Storage Virtualization
Storage VirtualizationStorage Virtualization
Storage Virtualization
 
05 Dios Existe
05 Dios Existe05 Dios Existe
05 Dios Existe
 

Similar to Monitoreo de MySQL y PostgreSQL con SQL

Thomas+Niewel+ +Oracletuning
Thomas+Niewel+ +OracletuningThomas+Niewel+ +Oracletuning
Thomas+Niewel+ +Oracletuningafa reg
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXzznate
 
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 optimizationManish 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 PostgreSQLCommand 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 PostgreSQLMark Wong
 
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 ServerStephen 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 SlidesSeveralnines
 
(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 FeaturesAmazon 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 ashmastersKyle Hailey
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshootingNathan Winters
 
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 ConferenceSeveralnines
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикAgnislav Onufrijchuk
 
Super scaling singleton inserts
Super scaling singleton insertsSuper scaling singleton inserts
Super scaling singleton insertsChris 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 DatabasesEmanuel 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 scEmanuel Calvo
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on awsEmanuel Calvo
 
PostgreSQL and Sphinx pgcon 2013
PostgreSQL and Sphinx   pgcon 2013PostgreSQL and Sphinx   pgcon 2013
PostgreSQL and Sphinx pgcon 2013Emanuel Calvo
 
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAYPostgreSQL FTS Solutions FOSDEM 2013 - PGDAY
PostgreSQL FTS Solutions FOSDEM 2013 - PGDAYEmanuel Calvo
 
LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)LSWC PostgreSQL 9.1 (2011)
LSWC PostgreSQL 9.1 (2011)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

Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 

Recently uploaded (20)

Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

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