Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [database-internals]

For technical questions about the internal workings of the database engine.

4
votes
1answer
41 views

SQL Server 2016 still uses mixed_extent_allocation in TempDB

Today I was troubleshooting a problem on TempDB on SQL Server 2016 SP2 using extended events and added the mixed_extent_allocation and transaction_log event to my trace. I expected ...
4
votes
2answers
404 views

Why does an index rebuild requires a Sch-M lock?

I don't see why an index rebuild would require a Sch-M lock on the given index.
2
votes
2answers
55 views

When does MySQL begin to start sending data to a client?

I am working on MySQL 5.7 with the default configuration of InnoDB storage engine. I have two questions each for a different scenario and need to know the internal working on how MySQL sends data to ...
0
votes
1answer
16 views

Will Postgresql statements execute synchronously if autocommit=true?

If a single application thread sends a series of INSERT statements and autocommit=true, will the statements be executed synchronously on the server? I read that on the postgres server side, "there ...
2
votes
1answer
64 views

How to find function definition

How can I find the definitions of below system functions in SQL Server: has_access permission_name I tried with DAC connection but getting below error: Msg 15009, Level 16, State 1, Procedure ...
11
votes
1answer
427 views

Why is this stream aggregate necessary?

Check out this query. It's pretty simple (see the end of the post for table and index definitions, and a repro script): SELECT MAX(Revision) FROM dbo.TheOneders WHERE Id = 1 AND 1 = (SELECT 1); ...
0
votes
2answers
81 views

How to understand Composite Primary Key when it comes to storage (in Mysql)?

I can image how rows will be arranged in a single database page as primary key order (example an auto-increment key) after reading this post. But I wonder how it will in the case of composite primary ...
5
votes
0answers
71 views

dm_os_memory_cache_clock_hands understanding

As I mentioned in this question I'm trying to understand the working of clock hands. Simply put clock hands move when there is memory pressure so that cache entries can be removed or the cost can be ...
1
vote
1answer
60 views

sql server cache clock hands

I'm doing some research about how to troubleshoot local memory pressure. Correct me if I'm wrong but as I understand it is that SQL Server uses a CLOCK algorithm for the cache- and userstores. Each ...
0
votes
2answers
46 views

No 'Copying to tmp table' state in profiling a mysql query

I have a table with 100k rows CREATE TABLE `small_table` ( `pk` int(11) NOT NULL AUTO_INCREMENT, `varc` varchar(255) DEFAULT NULL, `txt` text, PRIMARY KEY (`pk`) ) ENGINE=InnoDB ...
6
votes
1answer
329 views

Measuring plan eviction

We have a SQL Server 2016 SP1 with max memory set to 24GB. This server has a high numbers of compiles, only 10% of these compiles are from Ad-Hoc queries. So the newly compiled plans should be stored ...
1
vote
1answer
35 views

How are page splits determined internally in MySQL?

Going through this answer for a stack-overflow question, I found a fact that In The physical structure of InnoDB index pages I describe the Last Insert Position, Page Direction, and Number of ...
3
votes
1answer
74 views

leaf_allocation_count in dm_db_index_operational_stats not changing on insert bulk

I was doing some index maintenance on a SQL Server 2016 SP2 CU2 and I noticed something I couldn't explain. I've a clustered index on a table of about 66 million rows and rows are added throughout ...
28
votes
1answer
2k views

Why is a scan faster than seek for this predicate?

I was able to reproduce a query performance issue that I would describe as unexpected. I'm looking for an answer that's focused on internals. On my machine, the following query does a clustered index ...
0
votes
2answers
93 views

Extent Allocation Mechanism in SQL Server 2017

I was looking at the SQL Server 2017 Documentation for page and extent allocations. What I got to know from online resources and sessions in SQL conferences: Starting with SQL Server 2016, Uniform ...
11
votes
1answer
93 views

List ROW_OVERFLOW_DATA pages for a specific table

I'm attempting to get a list of pages for a table that has rows with ROW_OVERFLOW_DATA. I can get the list of allocated pages from the undocumented DMV, sys.db_db_database_page_allocations, however, ...
3
votes
2answers
48 views

PostgreSQL GiST compress skeleton when no compression required

I'm trying to implement my GiST index, where storage type is the same as column type (bytea). They are even going to have same length because these are bitarrays and unions are just disjunctions of ...
3
votes
1answer
96 views

How large is SQLites minimum data storage overhead and what generates them?

Motivation: In my company there exists the (probably strange) idea to store pure time series data in a normal SQL table (instead of using BLOBs or just binary files which would probably be a better ...
0
votes
0answers
44 views

SQL Server locking question

Could you please clarify how SQL Server locking works internally during an index seek? Lets look into such case. We have a table TEST that consists of three columns Col1, Col2, Col3. Col1 has a ...
2
votes
1answer
115 views

Performance difference in accessing differrent columns in a Postgres Table

Created a table with 200 bigint column, 200 varchar column. (Postgres 10.4) create table i200c200 ( pk bigint primary key, int1 bigint, int2 bigint,....., int200 bigint, char1 varchar(255),......, ...
8
votes
1answer
189 views

Index Seek Operator Cost

For the AdventureWorks sample database query below: SELECT P.ProductID, CA.TransactionID FROM Production.Product AS P CROSS APPLY ( SELECT TOP (1) TH.TransactionID FROM ...
3
votes
2answers
565 views

In what cases are BLOB and TEXT stored in-line on InnoDB?

I've googled this and can't find it, you can see Rick James mention it here. ... BLOB and TEXT are not always stored separately The answer on What is the difference between MySQL VARCHAR and TEXT ...
4
votes
2answers
241 views

Advantages to column constraints over table constraints

Is there any advantages whatsoever, other than style to writing this, CREATE TABLE foo ( a int PRIMARY KEY, b int ); And then, CREATE TABLE bar ( a int REFERENCES foo, c int ); Over, ...
1
vote
1answer
99 views

Does a backup include dropped, hidden columns still in a table's physical structure?

If I have a table with an NVARCHAR(MAX) column and I drop it, the standard way to reclaim the space it used is to either: Rebuild the clustered index or Run DBCC CLEANTABLE If I didn't perform ...
3
votes
1answer
78 views

PostgreSQL priority between CTE and real table

Is there some kind of priority ranks assigned to CTE and table name ? For instance, if I have a table called table_a in the public schema, and I create a CTE table named table_a using WITH, which ...
2
votes
0answers
53 views

How is page data rearranged after clustered index is created?

Can anyone please explain what happens at the page level when clustered indexes are created? How do pages rearrange data once clustered indexes are created?
8
votes
1answer
288 views

Why does a Set Returning Function (SRF) run slower in a FROM clause?

This is a database-internals question. I'm using PostgreSQL 9.5, I'm wondering why Set Returning Functions (SRFs), also known as Table Valued Functions (TVFs) run slower when in a FROM clause, for ...
0
votes
1answer
59 views

Is file a basic form of database? [duplicate]

I’m having an interesting conversation with my friend who’s a developer. I’m a database admin. I say file is a basic form of database. I believe whatever that stores data can be called a database. He ...
1
vote
1answer
51 views

How can we foresee (and configure) B-Tree and R-Tree indexes width and depth in PostgreSQL? [closed]

The B-Tree and the R-Tree are two similar index structures that PostgreSQL offers in its implementation. Both structures can have at most m children per node and as other tree structures, children ...
7
votes
1answer
686 views

Internally, how does OpenRowset(TABLE …) work?

I see a lot of internal views, such as sys.syscomments making calls to CROSS APPLY OpenRowset(TABLE, oid). I am wondering how this function operates and what it's reading from. Let's look at one ...
3
votes
1answer
809 views

What is the significance of the principal_id in sys.schemas?

What is the meaning of the principal_id in sys.schemas and when would it ever be different from schema_id? 1> SELECT LEFT(name,20), schema_id, principal_id FROM sys.schemas; 2> GO ...
2
votes
2answers
368 views

What is an “Obfuscation key” in SQL Server?

Jokes aside, what is an "Obfuscation key"? I'm just going off the docs. sys.sysclsobjs Exists in every database. Contains a row for each classified entity that shares the same common properties ...
2
votes
1answer
111 views

How does the sys.objects Catalog View pull from itself? [duplicate]

I'm using this stored procedure called OBJECT_DEFINITION as was suggested. It's helping me wrap my head around the SQL Server system. However, there is one area that I can't yet figure out. On this ...
5
votes
3answers
785 views

What is the significance of the trailing dollar sign `$` on identifiers in SQL Server?

Dumping some internal views, such as sys.system_objects as done in this question I see that some identifiers end with a dollar-sign $ CREATE VIEW sys.system_objects AS -- cutout FROM sys....
6
votes
3answers
3k views

Making sense of sys.objects, sys.system_objects, and sys.sysobjects?

In this question I was writing a query using sys.sysobjects. However, one of the answers mentioned sys.system_objects. I'm just wondering what is the difference between these tables? sys.objects sys....
-3
votes
2answers
353 views

What internal functions are undocumented in SQL Server?

I just read about fn_dblog, and fn_dump_dblog. I was wondering how do I know what functions like this exist, I'm not the only one either, the comments are scattered with people wanting to know more, ...
2
votes
1answer
406 views

What is a SQL Server “lop”?

The tool ldfreader.exe has an option called -lopFilter -lopFilter Dump only records with these LOP. (short form: -l) But, I don't see anything explaining what a LOP is. What is known about "...
4
votes
1answer
317 views

Can I extend SQL Server with C++ or C?

So, I created a PE32+ DLL, in an attempt to load it into SQL Server, $ file example_dll.dll example_dll.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows but when I try to compile it as ...
-5
votes
2answers
53 views

Creating my own database [closed]

I need to create my own database. Which language is comfortable for it? C or Java or any other language? Please tell me step by step process in creating data base.
1
vote
2answers
180 views

How do I use SQL Server's “Hekaton”?

The SQL Server 2017 version on Linux comes packaged with a utility called mtlogreader.exe that is absent from the Windows distribution, MtLog Reader - Dump Hekaton MtLog files Usage: \\VBOXSVR\mssql\...
2
votes
1answer
291 views

What differences are there with SQL Server 2017's packaging of `Binn` on Linux and Windows?

Knowing that the Binn is packaged differently on Windows and Linux, I'm wondering what differences there are between the two? Do they come with different utilities? On Linux Binn is distributed in a ...
1
vote
1answer
291 views

What are these SFP files that SQL Server distributes?

What are the SFP files that come with SQL Server 2017? /opt/mssql/lib/sqlservr.sfp /opt/mssql/lib/sqldkxplat.sfp /opt/mssql/lib/secforwarderxplat.sfp /opt/mssql/lib/system.common.sfp /opt/mssql/lib/...
5
votes
1answer
186 views

On SQL Server 2017 (Linux), where is the Resource Database persisted (located on disk)?

In my default install of SQL Server 2017 on Linux, under /var/opt/mssql/data I see the following databases, master.mdf - master Database - Records all the system-level information for an instance of ...
1
vote
2answers
175 views

Where can I find documentation on SQL Server internals?

I know, well I've been told, Microsoft has a per-dev doc system under MSDN. Specifically, I'm looking for docs on the internal format of the WAL log. Is this documented anywhere? Certainly third ...
1
vote
2answers
710 views

Where does SQL Server store the SA password and SQL Server password policy?

On Linux, where does SQL Server store the "SQL Server password policy" and the SA user's password? I get it, "password" isn't secure. ERROR: Unable to set system administrator password: Password ...
1
vote
2answers
215 views

Hash function and custom C type for PostgreSQL

I am creating a custom type for PostgreSQL. The type is as follow: typedef struct { unsigned long prefix; unsigned long long id; } CustomType; I have build all the in and out functions. ...
1
vote
1answer
208 views

What is the 131072 in the call to lo_open()

ByteA to BLOB conversions typically make a call to lo_open(), CREATE OR REPLACE FUNCTION make_lo(bytea) RETURNS oid AS $$ DECLARE loid oid; fd integer; bytes integer; BEGIN loid := lo_creat(-...
4
votes
3answers
2k views

Why does the optimizer choose nested loops over merge joins here?

I have 3 tables. #a is main one and two secondary tables, #b and #c. create table #a (a int not null, primary key (a asc)) ; create table #b (b int not null, primary key (b asc)) ; create table #c (c ...
3
votes
1answer
456 views

How does SQL Server reuse reserved pages after deleting a table

I just want to know: How SQL Server reuses reserved space after dropping a 1GB table? (call the table T1) How SQL Server reuses reserved space after truncating a table? (call this table T2) Both are ...
2
votes
0answers
88 views

Hash Match Probe Residual [duplicate]

Experts, I am trying to learn more about the CONVERT_IMPLCIT and Probe Residual. Can someone explain to me why the following test script cause Probe Residual? My understanding is if both join ...