Posts

What is idempotent operation

Idempotent, in programming and mathematics, is a property of some operations such that no matter how many times you execute them, you achieve the same result. In programming, idempotent can be a property of many different code elements, including functions, methods, requests and statements. Idempotent is a language-agnostic property: It means the same thing in any programming context. Here’s a simple demonstration of idempotent in HTTP requests: HTTP GET requests are a method of retrieving specified data from a source, such as getting a bank account balance. GET requests are idempotent: Accessing the same data should always be consistent. On the other hand, POST requests are designed to change the target, such as adding a sum to a bank account. As such, a POST request should change the result and that means it’s not idempotent. In computing, an idempotent operation is one that has no additional effect if it is called more than once with the same input parameters. For example, removing ...

How to truncate the Slow Query Log on AWS RDS MySQL

I was in need to empty the slow_log table in MySQL database inside a Amazon Relational Database System to look into a performance issue. But I got the below error. I was surprised because I had login with the master user of the RDS. mysql> use mysql mysql> truncate table slow_log Error Code: 1044. Access denied for user 'dbroot'@'%' to database 'mysql' On surfing the internet I got this and it resolved my problem. "Amazon RDS will not give you SSH access to its database server. That means you don’t have the opportunity to view any of the log files, even the slow query log, for the database. But RDS provides a way to play with the slow queries. If your slow queries are many then this table will hold too many queries to handle. You cannot truncate the table or delete any row from there. There is only a way to move all the data from this table to another table named ‘slow_log_backup’, making the slow_log table empty. To do so you have to run a stored pro...

what is character encoding and decoding

Characters are abstract entities that can be represented in many different ways. A character encoding is a system that pairs each character in a supported character set with some value that represents that character. For example, Morse code is a character encoding that pairs each character in the Roman alphabet with a pattern of dots and dashes that are suitable for transmission over telegraph lines. A character encoding for computers pairs each character in a supported character set with a numeric value (also known as code point) that represents that character. A character encoding has two distinct components:   An encoder, which translates a sequence of characters into a sequence of numeric values (bytes). A decoder, which translates a sequence of bytes into a sequence of characters.    A computer can only work with 0s and 1s. It does not understand human languages like English, Hindi etc. Hence you need to mention the correct character set while either rendering ...

Understanding character set and collations

An important yet most ignored part in software concepts is Character Set and Collations. It is a vital thing that every developer must familiar with. The objective of this article is to make you understand what is meant by character set and collations. I will take help of MySQL in the process. Please remember that character set and collation are valid for text data like CHAR, VARCHAR, TEXT etc. It has no significance for data of type INT, BINARY etc. Character Set decides which characters you are allowed to use while storing information in your application. Collation decides how the two piece of information will be compared or sort in case you do an operation on the data in your application. mysql> CREATE TABLE `person` -> ( -> `id` int not null auto_increment, -> `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, -> PRIMARY KEY (`id`), -> UNIQUE KEY (`name`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode...

MongoDB database Data Types

MongoDB is a No SQL database that uses document as its data structure to store user's data. MongoDB is a schema-less database in the sense that you do not require to define your fields in advance as well as different structured document can reside in the same collection. This is not possible in case of traditional RDBMS like MySQL, SQL Server, Oracle etc. A document in MongoDB consists of key value pairs. Keys are written as strings but values can belong to one of the several data types allowed in MongoDB. Please always refer to the documentation or online resources for your specific version of MongoDB as an application features are always tend to change. DataType Description String This commonly used datatype contains a string of text (or any other kind of characters). This datatype is used mostly for storing text values (for example, "Country" : "India"}. Integer (32b and 64b) This type is used to store a numerical value (for example, { ...

Online editors and useful links

HTML, CSS and JavaScript jsFiddle HTML, CSS and JavaScript Demo - Liveweave Unix SHELL ShellCheck - shell script analysis tool Bash Pitfalls - Greg's Wiki Bash Guide - Greg's Wiki

select ends with killed in mysql

I ran a query in mysql and it hangs for a while and then I get killed as a response. mysql> select * from usagehistory; Killed SHELL:~$ SHELL:~$ date Thu Mar 14 06:26:17 UTC 2019 SHELL:~$ Reason The mysql process/client itself runs out of memory and is terminated by the OS. I do not have a good view of the implementation, but it appears that mysql is trying something like pulling the whole table into memory to do the select *. You can use the --quick mysql option to not buffer the results in memory. I also found out that the data in table is around 2 GB and Memory in my jump-box is around 1 GB. Two more proofs that I see in my jump box (where mysql is run) system is: 1. I see OOM messages in syslog. root@ip-XXX-XXX-XXX-XXX:~# grep mysql /var/log/syslog | less Mar 14 06:25:40 ip-XXX-XXX-XXX-XXX kernel: [529731.301028] mysql invoked oom-killer: gfp_mask=0x24201ca, order=0, oom_score_adj=0 Mar 14 06:25:40 ip-XXX-XXX-XXX-XXX kernel: [529731.301032] mysql cpuset=/ mems...
Back To Top