Sunday, 17 April 2016

Baby sleep - tip 1

If the baby is struggling to sleep after being held, a tip is to place a muslin under your T-shirt whilst the baby is being fed.

Then, when the baby is placed in their cot / basket / bed for their sleep, place the muslin in with them at the same time.

The theory is, your scent is transferred to the muslin, so when its placed in with the baby, they can smell the scent, and are tricked into thinking that they're still close to the parent, and feel secure, and so they'll sleep.

Information in this blog is from my own personal experience / observation and only for my own reference.  If you find it useful, then great, buy it shouldn't be considered "gospel", and your own experience may and will differ as each baby / situation is different.

Baby Sleep cycles

Everyone has  sleep cycles.
In babies, these last 45 minutes.

Babies can stir, or wake themselves up in between these cycles, and my squirm, or cry for a few seconds.

This is normal, and shouldn't be concerning.

Leave them alone,  and observe.

The baby will self-settle, and drift back off to sleep.

This self-settling is a crucial, and important skill that all babies need to develop so that they remain calm and relaxed as the grow.

Information in this blog is from my own personal experience / observation and only for my own reference.  If you find it useful, then great, buy it shouldn't be considered "gospel", and your own experience may and will differ as each baby / situation is different.

Baby Swaddling, self-settling

Babies often have involuntarily moments.  This is normal as the muscle control is still developing.

When babies are sleeping, these movements can actually cause the baby to wake them selves, either from the jolt of their own movements, or when they hit themselves in the face.

To help with their sleep, to keep them undisturbed, simply swaddle the babies arms.  This helps keep the babies warm, stops involuntarily arm movements, and gives the baby the safe reassurance, similar to when the were in the womb.

Information in this blog is from my own personal experience / observation and only for my own reference.  If you find it useful, then great, buy it shouldn't be considered "gospel", and your own experience may and will differ as each baby / situation is different.

Baby feeding - bottles / teats

Bottles and teats, and blockages.

Bottles, and teats all come in different shapes, sizes.

Different sized teats means that they're designed for potentially a better, or more comfortable fit in the babies mouth.

The different "numbered" teats generally mean that the "hole" at the top is a different size.  This means that they can "flow" more milk during the feed.
Generally speaking the teats are either numbered from 0 to 3, or by babies months starting from "0+", progressing to "3 months+" and so on.

Some teats have a "valve" in them (for example Tommee Tippee teats have them) to help with the "return" of air back into the bottle as the babies drinks the milk out of the bottle.

At some point during feeding your baby, you may wonder why isn't the milk being drank, even if the baby is swallowing.
This may be due to the teat nozzle becoming blocked with the milk power.
This happens, and isn't a big deal.

Simply remove the bottle from the babies mouth.  With the bottle upright verticle, with the teat pointing upwards, give the bottle a gentle firm squeeze.
This is to push some air that's at the top of the bottle out through the teat nozzle.
This will effectively squirt the blockage out.
It helps if you position the nozzle close to, but not touching your own lips.
You'll then feel a gentle jet of air on your lips when the blockage has been squirted out.

Alternatively, with the bottle removed from the baby, with clean hands / fingers, give the teat nozzle a quick squeeze, or roll the nozzle between your index finger and thumb.  Depending on the size of the nozzle, you may even be able to see through the opening, down into the milk.
You only want to visually inspect the nozzle, ensuring no blockage, and then squeeze the bottle again so that a jet of air hits your lips, confirming that the nozzle is clear.

Now that its clear, continue feeding your baby.

As your baby grows, and gets stronger at sucking from the bottle, blocked nozzles become less if an issue, as the baby will be able to suck any blockages from undissolved milk powder straight in during their feed.

Information in this blog is from my own personal experience / observation and only for my own reference.  If you find it useful, then great, buy it shouldn't be considered "gospel", and your own experience may and will differ as each baby / situation is different.

Baby blog - feeding

Bottle feeding.

Have a baby bib / muslin ready, and perhaps a cushion to place under your arm for support.

During the first few days, the baby may appear to have "pool" the milk in their mouth when drinking.  This is probably down to the fact that they're getting used to drinking larger amounts of milk in one sustained period.

Also, when born, their stomach is only the size of a plum stone, so it fills up quickly.

So, burp regularly (every 15ml) to start with.

Also, with the bottle, ensure a that its sealed around the babies mouth like a nipple would have been.  This helps when the baby tries to swallow, as the milk is less likely to flow out of their mouth, and down their throat.

If the baby cries, is mildly distressed during a milk feed, it'll just be wind / air that they have swallowed during the feed.

Prop up the baby in one hand, by placing / leaning the babies chest in palm of your left hand, thumb and ring finger under each armpits, and head resting on the middle and index fingers, and rub their back with the other hand.
The majority of the babies weight will be supported by the finger and thumb that are under the armpits, and the palm of your hand, so their leaning forward into your hand if that makes sense.

Any trapped air / pocket of gas will "burble" up eventually, and the baby will burn this out.

Alternatively, you may notice that the baby passes wind during the feeding session which is also a good sign.

During a feed, the baby will often fall asleep, as the milk is soporific.

Simple massage the babies leg / foot during the feeding session, and gently push the bottle teat into the babies roof of their mouth to keep them awake / stimulated, to remind them that their still feeding, and that the bottle is still in their mouth.

As a visual queue, you can watch the babies throat as they swallow so that you can see the baby drinking.

Information in this blog is from my own personal experience / observation and only for my own reference.  If you find it useful, then great, buy it shouldn't be considered "gospel", and your own experience may and will differ as each baby / situation is different.

Saturday, 9 April 2016

SQL SERVER Indexes, Clustered, Nonclustered, Covering, Include, Key Ideas

Indexes

A database index is very much like the index in a book: the book index has an alphabetized list of topics with page numbers to the location of the data.

A database index has an ordered list of values (made up of one or more table columns), with pointers to the row in which the value and its corresponding data reside.
Without indexes, any query or data modification causes the SQL engine to search the referenced tables from the top down. This is akin to searching for a piece of information in a book by reading it from page 1. A single well-placed index can shorten your query time from dozens of minutes to under a second.

There are two kinds of indexes in SQL Server: clustered and nonclustered.

Clustered

A table can only have one clustered index, because the clustered index sorts the rows in the table itself.
Every table in the database should have a well-chosen clustered index to aid data retrieval and modification.

Ideally a clustered index should be:
·         Small (of a small data type)
The clustered index key is the pointer contained in each clustered index. If you therefore have a clustered index key that is large – for example, a 16 bit UNIQUEIDENTIFIER – indexes will take up much more space than if the clustered index key were smaller (e.g., a 4 bit INT).
·         Unique or highly selective – The more selective an index, the more efficient.
·         Ever-increasing – The clustered index orders the rows in the table. If the clustered index key is ever increasing, new rows are added to the end of the table. Otherwise, new rows are inserted in the middle of the table, and the database engine must reorganize the data on disk more often.
·         Static – A frequently changing clustered index key will cause rows to be reordered within the table, causing unnecessary overhead.

Nonclustered

A nonclustered index is a separate physical structure from the underlying table. It contains the values for the included columns – called index keys – along with pointers back to the corresponding table row. On a table that has a clustered index, each nonclustered index’s pointer is the clustered index key.

Note that a nonclustered index is ordered, but it does not alter the order of the rows in the table.

There are few hard and fast rules for indexing. You have to see what works for your database over time. There are whole books dedicated to indexing strategies.
Here are a few general indexing guidelines:
·         Each table should have a clustered index that is (ideally) small, selective, ever increasing, and static. (Note that a table without a clustered index is called a heap.)
·         Implement nonclustered indexes on foreign key relationships – in other words, on columns that are likely to be used in JOINs.
·         Implement nonclustered indexes on columns that are frequently used in WHERE clauses.
·         Do not implement single-column indexes on every column in a table. This will take up space unnecessarily, and cause high overhead on INSERTs and UPDATEs.
·         In multi-column indexes, list the most selective (nearest to unique) first in the column list. For example, when indexing an employee table for a query on social security number (SSN) and last name (lastName), your index declaration should be
 CREATE NONCLUSTERED INDEX ix_Employee_SSN
 ON dbo.Employee (SSN, lastName);
·         For the most often-used queries, consider a covering nonclustered index. A covering index is one that contains all the columns requested from a table.
CREATE INDEX IX_BORK_222 ON dbo.BORK (col3, col1, col2)
Convering indexes risk being wide objects and taking up lots of space.

Include


To understand INCLUDE, you first must understand (a little bit) the structure of an index.
An index is organized in a b-tree hierarchy – each node of data (in the case of our index IX_BORK_111, col3) has two nodes beneath it – the left node higher in the sort range, and the right node lower, like this:

 ……….5……..
 …3……….7….    child nodes of 5
 1…4……6…9..   leaf nodes

3 and 7 are the child nodes of 5.  1 and 4 are the child nodes of 3. 
The lowest level nodes are called leaf nodes, so 1,4,6,and 9 are the leaf nodes.
The SQL engine walks through the tree to find the values it needs…

If we create our covering index like this:
CREATE INDEX IX_BORK_222 ON dbo.BORK (col3, col1, col2)
then each node in the tree will contain values for col3, col1, and col2.  That can take up a lot of space.  

But in our query, we don’t need to search based on col1 and col2….we only search based on col3.  
The other two columns are just there to be returned in the SELECT statement.

About INCLUDE

INCLUDE lets us make the index smaller, while still supplying our SELECTed columns.
First, here’s the index declaration: CREATE INDEX IX_BORK_333 ON dbo.BORK (col3) INCLUDE (col1, col2) 

Each node in the tree will contain the value for col3. 
But only the leaf level nodes will hold the values for col1 and col2.
That’s how INCLUDE makes the index smaller – the rest of the tree doesn’t contain extra, unused information.
The SQL engine performs its search based on col3, finds the leaf level node(s) that match, and there at the leaf level is the rest of the information we need.

Key Ideas Review


Key ideas mentioned:

·         Clustered index – small, unique (or highly selective), ever increasing, static index on a table. (only one CI can exist on a table)
·         Clustered Index Key – the pointer to the row in the table.
·         Indexes let queries find data faster.
·         Nonclustered indexes are separate objects from tables.
·         Index Key – the values contained in the nonclustered index.
·         A covering index is ideal – it gives the query everything it needs, without having to touch the table itself (that’s called a bookmark lookup).
·         Nonclustered indexes take up space, so you don’t necessarily want a lot of really wide covering indexes. Use with discretion.

One final point: Remember that indexes must be updated every time data is updated or inserted into the table. The more indexes, the longer your inserts and updates will take.

Indexing is a balance between supplying enough to support your read operations, and keeping insert/update overhead low.