database-tuning

MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?

别说谁变了你拦得住时间么 提交于 2019-12-10 17:53:44
问题 UPDATE: I've answered this myself below. I'm trying to fix a performance issue in a MySQL query. What I think I'm seeing, is that assigning the result of a function to a variable, and then running a SELECT with a compare against that variable is relatively slow. If for testings sake however, I replace the compare to the variable with a compare to the string literal equivalent of what I know that function will return (for a given scenario), then the query runs much faster. For example: ... SET

Tune a simple inner join query

ε祈祈猫儿з 提交于 2019-12-02 19:41:00
问题 I am trying hard to tune my SQL query. I am relative not an expert in tuning SQL as i come from MDBMS tech Here is the query SELECT /*+ parallel(f 4) */ F.DM_CUSTOMER_DKEY, P.PRODUCT_YEAR, SUM(F.ADVG_COST_ACTUALS) advg_cost_actuals FROM DM_CUST_RENEWAL_ADV_FACT F INNER JOIN DM_PRODUCT_HIERARCHY p ON F.DM_PRODUCT_HKEY = P.DM_PRODUCT_HKEY GROUP BY F.DM_CUSTOMER_DKEY, P.PRODUCT_YEAR ORDER BY P.PRODUCT_YEAR I know fact table has multi billion records. Though, I am not sure how many as my count (*

SQL Server audit logout creates huge number of reads

爱⌒轻易说出口 提交于 2019-11-28 10:44:12
I'm using SQL Server Profiler to figure out what process are consuming SQL process and I found that the event class Audit Logout is causing a huge number of reads and consume cpu process. Is it normal? Or do I have something wrong in the SQL Server configuration? The audit logout event aggregates a lot of its values like reads/writes, connection times, etc. from the time the connection was opened. See http://msdn.microsoft.com/en-us/library/ms175827.aspx - the definition for your specific question added here: Reads Number of logical read I/Os issued by the user during the connection. So

How to profile MySQL

一世执手 提交于 2019-11-27 21:08:26
How do I profile a MySQL database. I want to see all the SQL being run against a database. I know you can do this: set profiling=1; Run your slow query (eg SELECT * FROM messages WHERE fromaddress='xxx'; SHOW PROFILES; But this seem to only apply to stuff run on the command line, I want to see the results from running a website. You want the query log - but obviously doing this on a heavy production server could be... unwise. Matija That worked for me on Ubuntu. Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Look for the section that says “Logging and

How to configure MongoDB Java driver MongoOptions for production use?

不想你离开。 提交于 2019-11-27 16:35:41
I've been searching the web looking for best practices for configuring MongoOptions for the MongoDB Java driver and I haven't come up with much other than the API. This search started after I ran into the "com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection" error and by increasing the connections/multiplier I was able to solve that problem. I'm looking for links to or your best practices in configuring these options for production. The options for the 2.4 driver include: http://api.mongodb.org/java/2.4/com/mongodb/MongoOptions.html autoConnectRetry connectionsPerHost

SQL Server audit logout creates huge number of reads

試著忘記壹切 提交于 2019-11-27 03:46:02
问题 I'm using SQL Server Profiler to figure out what process are consuming SQL process and I found that the event class Audit Logout is causing a huge number of reads and consume cpu process. Is it normal? Or do I have something wrong in the SQL Server configuration? 回答1: The audit logout event aggregates a lot of its values like reads/writes, connection times, etc. from the time the connection was opened. See http://msdn.microsoft.com/en-us/library/ms175827.aspx - the definition for your

How to configure MongoDB Java driver MongoOptions for production use?

北城余情 提交于 2019-11-26 18:43:14
问题 I've been searching the web looking for best practices for configuring MongoOptions for the MongoDB Java driver and I haven't come up with much other than the API. This search started after I ran into the "com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection" error and by increasing the connections/multiplier I was able to solve that problem. I'm looking for links to or your best practices in configuring these options for production. The options for the 2.4 driver

How can I time a code segment for testing performance with Pythons timeit?

落花浮王杯 提交于 2019-11-26 12:49:21
I've a python script which works just as it should, but I need to write the execution time. I've googled that I should use timeit but I can't seem to get it to work. My Python script looks like this: import sys import getopt import timeit import random import os import re import ibm_db import time from string import maketrans myfile = open("results_update.txt", "a") for r in range(100): rannumber = random.randint(0, 100) update = "update TABLE set val = %i where MyCount >= '2010' and MyCount < '2012' and number = '250'" % rannumber #print rannumber conn = ibm_db.pconnect("dsn=myDB","usrname",

Optimise PostgreSQL for fast testing

独自空忆成欢 提交于 2019-11-26 00:56:30
问题 I am switching to PostgreSQL from SQLite for a typical Rails application. The problem is that running specs became slow with PG. On SQLite it took ~34 seconds, on PG it\'s ~76 seconds which is more than 2x slower . So now I want to apply some techniques to bring the performance of the specs on par with SQLite with no code modifications (ideally just by setting the connection options, which is probably not possible). Couple of obvious things from top of my head are: RAM Disk (good setup with

Optimise PostgreSQL for fast testing

不羁的心 提交于 2019-11-25 20:03:56
I am switching to PostgreSQL from SQLite for a typical Rails application. The problem is that running specs became slow with PG. On SQLite it took ~34 seconds, on PG it's ~76 seconds which is more than 2x slower . So now I want to apply some techniques to bring the performance of the specs on par with SQLite with no code modifications (ideally just by setting the connection options, which is probably not possible). Couple of obvious things from top of my head are: RAM Disk (good setup with RSpec on OSX would be good to see) Unlogged tables (can it be applied on the whole database so I don't