Enums in MongoDB

Storing enum values in MongoDB as strings is perfectly fine, and yes, if you index the field I’d expect the performance to be comparable to indexed integer queries. It’s certainly more expressive than using integers. The only real downside is that they’ll take more space if your enum strings are somewhat long, but that’s a … Read more

Are unique indexes better for column search performance? (PGSQL & MySQL)

If your data are unique, you should create a UNIQUE index on them. This implies no additional overhead and affects optimizer’s decisions in certain cases so that it can choose a better algorithm. In SQL Server and in PostgreSQL, for instance, if you sort on a UNIQUE key, the optimizer ignores the ORDER BY clauses … Read more

How often should the indexes be rebuilt in our SQL Server database?

There’s a general consensus that you should reorganize (“defragment”) your indices as soon as index fragmentation reaches more than 5 (sometimes 10%), and you should rebuild them completely when it goes beyond 30% (at least that’s the numbers I’ve heard advocated in a lot of places). Michelle Ufford (a.k.a. “SQL Fool”) has an automated index … Read more

How to efficiently assign unique ID to individuals with multiple entries based on name in very large df

This approach uses .groupby() and .ngroup() (new in Pandas 0.20.2) to create the id column: df[‘id’] = df.groupby([‘LastName’,’FirstName’]).ngroup() >>> df First Second id 0 Tom Jones 0 1 Tom Jones 0 2 David Smith 1 3 Alex Thompson 2 4 Alex Thompson 2 I checked timings and, for the small dataset in this example, Alexander’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)