Posts

Showing posts from August, 2024

PL/SQL

PL/SQL PL/SQL stands for Procedural Language extensions to the Structured Query Language (SQL). PL/SQL can execute a number of queries in one block using single command. One can create a PL/SQL unit such as procedures, functions, packages, triggers, and types, which are stored in the database for reuse by applications. The PL/SQL engine resides in the Oracle engine. The Oracle engine can process not only single SQL statement but also block of many statements. Structure of PL/SQL Block: DECLARE     declaration statements; BEGIN     executable statements EXCEPTIONS     exception handling statements END; / Example : SET SERVEROUTPUT ON; SQL> DECLARE        var varchar2(40) := 'I love GeeksForGeeks' ;      BEGIN        dbms_output.put_line(var);      END;      / PL/SQL Functions PL/SQL functions are reusable blocks of code that can be used to perform specific tasks. They are...

Java Application Performance

Java Application Performance Java performance refers to the speed and efficiency of a Java application or system, and is typically measured by the amount of time it takes to complete a particular task or the amount of resources it uses to do so.  Performance is a critical factor in many applications, particularly those that require real-time processing, high throughput, or low latency. 5 Common Java Performance Problems   a) Memory Leaks and Out of Memory Errors   b) Thread Deadlocks   c) Garbage Collection   d) Code-Level Issues   e) Pool Connections Steps to improve the performance of Java applications:   1) Choose the Performance Parameters to Tune       Footprint - Memory and CPU       Throughput - Work       Latency - Time   2) Identify the System’s Limits   3) Use a Profiler to Handle Bottlenecks   4) Create a Performance Test Suite 8 Tips for Optimizing and Improving Java Performance: ...

Comparable vs Comparator in Java

Comparable vs Comparator in Java Java provides two interfaces to sort objects using data members of the class:   1) Comparable   2) Comparator Comparator A comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of the same class. public int compare(Object obj1, Object obj2): class Sortbyname implements Comparator<Student> {   // Method   // Sorting in ascending order of name   public int compare (Student a, Student b) {     return a.name.compareTo(b.name);   } } Comparable A comparable object is capable of comparing itself with another object. class Movie implements Comparable<Movie>{   public int compareTo (Movie m) {     return this.year - m.year;   } } using comparator we were able to use different attributes. using comparable we can use only one comparison.

JAVA8 Features

Java8 Features 1) Lambda Expressions : Concise functional code using ->. Lambda Expression basically expresses an instance of the functional interface, Lambda Expression provides a clear and concise way to represent a method of the functional interface using an expression. 2) Functional Interfaces : Single-method interfaces. An interface that contains only one abstract method is known as a functional interface. There is no restriction, that can have n number of default and static methods inside a functional interface. A functional interface is an interface that contains only one abstract method.  @FunctionalInterface annotation is used to ensure that the functional interface can’t have more than one abstract method. Runnable, ActionListener, and Comparable are some of the examples of functional interfaces.   Runnable –> This interface only contains the run() method.   Comparable –> This interface only contains the compareTo() method.   ActionListener –> ...

MetaSpace in Java 8

MetaSpace in Java 8 JVM Memory Structure: JVM defines various run-time data area which are used during execution of a program.  Some of the areas are created by the JVM whereas some are created by the threads that are used in a program. The memory area created by JVM is destroyed only when the JVM exits. The data areas of thread are created during instantiation and destroyed when the thread exits. JVM Memory Structure is divided into multiple memory area like heap area, stack area, method area, PC Registers etc. The heap area where all the java objects are stored. The heap is created when the JVM starts.  The heap is generally divided into two parts.  1) Young Generation( Nursery): All the new objects are allocated in this memory.  Whenever this memory gets filled, the garbage collection is performed.  This is called as Minor Garbage Collection. 2) Old Generation : All the long lived objects which have survived many rounds of minor garbage collection is stored i...

API Performance Tuning

API Performance Tuning Below are some of the metrics that need to consider while optimizing the performance of APIs/Services: 1) Response Time : Measures how quickly the APIs/Services are responding. 2) Payload and its size : Amount of data transported over the network. 3) Throughput : Number of times the APIs/Services are being invoked. Some of the techniques which can help to improve those: Caching Compression - Compressing the contents before transporting them over the network avoids the latency at the network layer. Compressions like Brotli or GZip can be used to achieve this. Payload Size - Sending only the needed data to the client reduces the network and other overheads in transporting the data to the client. Logging - Avoid excessive logging of data to the log files, as this makes the server spend time on logging instead of spending time processing the request. Optimizing the API/Service Code To optimize the code at the server level: - Caching frequently accessed contents on t...

SQL Query Optimization

SQL Query Optimization: 1. Use Indexes 2. Avoid SELECT DISTINCT 3. Use WHERE Clause instead of HAVING CLAUSE      SELECT name FROM table_name WHERE age>=18      SELECT age COUNT(A) AS Students FROM table_name GROUP BY age HAVING COUNT(A)>1; 4. Avoid Queries inside a Loop 5. Use Select instead of Select * 6. Add Explain to the Beginning of Queries 7. Keep Wild cards at the End of Phrases 8. Use Exist() instead of Count() 9. Avoid Cartesian Products 10. Consider Denormalization 11. Optimize JOIN Operations       Create queries with INNER JOIN (not WHERE or cross join) 12. Use LIMIT to sample query results 13. Run your query during off-peak hours SQL Performance Tuning Tools 1. SQL Sentry (SolarWinds) 2. SQL Doctor (IDERA) 3. Profiler (Microsoft) 4. SQL Defrag Manager (IDERA) 5. DB Optimizer (IDERA) 6. SQL Check (IDERA) 7. Foglight for SQL Server (Quest Software) 8. SQL Index Manager (Red Gate Software) 9. Qure Optimizer (DBSophic) 10. DB...