Posts

Showing posts from 2025

Cost of sorting (as in money cost)

 I'm watching a video on query tuning in Microsoft SQL Server and the tutor made an interesting point about sorts that probably also applies to Oracle as well. He argues that unless you're also using TOP to get the top N results (or something similar where a sort is required by another operation) you should not do sorts in the database but do them in the application layer.  His rationale is that SQL Server, like Oracle, is licensed per CPU; if you're using a cloud service then you will be billed per CPU allocated or by the execution time your code spends on the CPU.  Sorts are very CPU intensive, the example he showed took about 800ms to just return 2.5million rows unsorted but 3.5s (about 4.4 times as long) with a sort.  Applications are more likely to be licensed per user so it's probably cheaper to add more CPU there than in the database server.

Changing Oracle Database ID and Name (nid)

 Getting back into Oracle as a DBA I've been reading up and watching tutorials to try to get the old skills back and update to the new tools, last time I DBAed in anger we were still on Oracle 7 and 8i, 9i had been out a while and 10g was in early versions, but because much of our software was so old we weren't using it much.  I came across a tutorial on how to update the name and ID of a database.  This is useful if you have copied a database and want to rename the copy to stop it being confused with the old, or if you want to have it on the same machine as the old.  The database ID is an internal number used by Oracle to identify the database, it looks like the main reason you'd want to change the ID is if you use RMAN and want to have both in the same repository. PLEASE NOTE: The below is based on a tutorial I watched and has not been tested, errors and omissions are expected.  Before using in production do a few practice runs on sandbox databases.  Proc...