Most Popular

1500 questions
37
votes
2 answers

MySQL - Difference between using count(*) and information_schema.tables for counting rows

I want a fast way to count the number of rows in my table that has several million rows. I found the post "MySQL: Fastest way to count number of rows" on Stack Overflow, which looked like it would solve my problem. Bayuah provided this…
Programster
  • 513
  • 1
  • 4
  • 9
37
votes
7 answers

Is it okay to put dots in SQL Server database names?

If I use a database name with a dot in it in SQL Server (2005 or 2008), something like "MyApp.Sales", will this cause any problems?
Sean Kearon
  • 473
  • 1
  • 4
  • 6
37
votes
4 answers

UPDATE performance where no data changes

If I have an UPDATE statement that does not actually change any data (because the data is already in the updated state). Is there any performance benefit in putting a check in the WHERE clause to prevent the update? For example would there be any…
Martin Brown
  • 720
  • 1
  • 5
  • 15
36
votes
18 answers

How can I compare the schema of two databases?

Is there a way to find the differences in two SQL Server databases (schema only). One is local and the second is at a customer's site. We are experiencing problems with crystal reports running some reports and some code not executing and it would…
user1571430
  • 461
  • 1
  • 4
  • 3
36
votes
3 answers

How to speed up select distinct?

I have a simple select distinct on some time series data: SELECT DISTINCT user_id FROM events WHERE project_id = 6 AND time > '2015-01-11 8:00:00' AND time < '2015-02-10 8:00:00'; And it takes 112 seconds. Here's the query…
Sam
  • 637
  • 2
  • 6
  • 12
36
votes
3 answers

mysqldump: Got error: 1044: Access denied for user 'username'@'localhost' to database 'databasename' when using LOCK TABLES

mysqldump: Got error: 1044: Access denied for user 'username'@'localhost' to database 'databasename' when using LOCK TABLES I am able to loging properly and able to take full backup from SQLyog Tool but when i am trying to take backup from MySQL…
Md Haidar Ali Khan
  • 6,447
  • 9
  • 38
  • 60
36
votes
1 answer

PostgreSQL roles versus users, grant permissions

I'm currently learning the differences between PostgreSQL and MySQL as I've got a new project and I also intend to migrate my existing software from MySQL to PostgreSQL. I've actually started creating an HTML table with a comparison of commands (for…
John
  • 705
  • 1
  • 10
  • 22
36
votes
6 answers

Load Balancing with SQL Server

What exists today to do Microsoft SQL Server Load Balancing on Windows Server and being transparent to any programmatic access. Is this built in or does a solution have to be purchased? I'm trying to find out if there is a solution today that makes…
Robert Kozak
36
votes
8 answers

IntelliSense not working but it is enabled

This problem is really proving to be a tricky one (and quite annoying). In SQL Server Management Studio 2008, up until a few days ago my IntelliSense was working great. Then all of a sudden it stopped. The icon as it as enabled on the toolbar…
Thomas Stringer
  • 42,224
  • 9
  • 117
  • 154
36
votes
3 answers

At what point does one database per client become unfeasible?

For one of our systems, we have sensitive client data and store each client's data in a separate database. We have about 10-15 clients for that system. However, we're developing a new system that will have 50-100 clients, maybe more. I am thinking…
NibblyPig
  • 661
  • 1
  • 8
  • 14
36
votes
1 answer

How to reclaim disk space on PostgreSQL?

I have local installation of 9.1 database with few tables which had cca. 300 mio records and the database grew to about 20 GB. Afterwards I issued delete from command to delete all records from it (I should have used truncate, but I didn't know…
arcull
36
votes
4 answers

Use of HAVING without GROUP BY in SQL queries

In order to use HAVING in SQL queries , must there be a GROUP BY to aggregate the column names? Are there any special cases where it is possible to use HAVING without a GROUP BY in SQL queries? Must they co-exist at the same time?
Computernerd
  • 493
  • 1
  • 5
  • 8
36
votes
5 answers

Why is there still a varchar data type?

Many of my databases have fields defined as varchars. This hasn't been much of a problem since I live and work in America (where the only language that exists is "American". ahem) After working with databases for about 5 years, I've found I…
RLH
  • 927
  • 1
  • 8
  • 16
36
votes
6 answers

Arbitrarily ordering records in a table

A common need when using a database is to access records in order. For example, if I have a blog, I want to be able to reorder my blog posts in arbitrary order. These entries often have lots of relationships, so a relational database seems to make…
Tom Marthenal
  • 463
  • 1
  • 4
  • 6
36
votes
2 answers

Is there a graceful or safe restart for mysql like for apache httpd?

I would like to restart mysql gracefully just like httpd where threads are served before restart. I would dislike queries breaking.
giorgio79
  • 1,407
  • 7
  • 19
  • 19