Den moderne arbejdsplads er i stigende grad afhængig af mødelokaler til at fremme samarbejde, men dette skift medfører også stigende sikkerhedsudfordringer.
Efter min egen personlige erfaring, er fordelen at det er nemmere at vedligeholde f.eks. et galleri i MySQL, fordi du kun skal bekymre dig om hvad der ligger dér og ikke rode med filsystemet. Det er derfor også nemmere at lave backup/restore.
Ulempen må være dårligere performance (har dog aldrig testet)
Ja, og jeg fortryder at jeg lagde dem i databasen, gör det aldrig igen. Er det et enkelt billede eller lignende der skal kaldes på så OK, men ikke et helt galleri.
Ok, jeg lader lige sprgm. så åben lidt endnu... vil lige se om der kommer inputs fra andre :-) Men alle der har deltaget og som er interesseret i points skal bare smide et svar
No points for me ;o) taskmgr>>Desvärre ingen dokumenterede resultater, kun mine egne erfaringer.
Synes godt om
Slettet bruger
14. juli 2004 - 12:19#16
En anden relevant ting er, at hver tabel i MySQL er en fil, og derfor er underlagt de begrænsninger for filstørrelser, som operativsystemet sætter. Alt efter hvilket operativsystem kan grænsen være på 2 GB, 4 GB eller ikke-eksisterende (med nutidige harddiske).
using System; using System.Threading; using System.Data; using ByteFX.Data.MySqlClient;
public class PicTestThread { private int n; private int npics; private int picsize; public PicTestThread(int n, int npics, int picsize) { this.n = n; this.npics = npics; this.picsize = picsize; } public void Run() { PicTest.CheckN(n, npics, picsize); } }
public class PicTest { private const int N = 10000; public static void CreateTable(int npics, int picsize) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand cre = new MySqlCommand("CREATE TABLE pics (id INTEGER PRIMARY KEY, pic MEDIUMBLOB)", con); cre.ExecuteNonQuery(); MySqlCommand ins = new MySqlCommand("INSERT INTO pics VALUES (@id, @pic)", con); ins.Parameters.Add("@id", MySqlDbType.Int); ins.Parameters.Add("@pic", MySqlDbType.MediumBlob); for(int i = 0; i < npics; i++) { ins.Parameters["@id"].Value = i; byte[] data = new Byte[picsize]; for(int j = 0; j < picsize; j++) { data[j] = (byte)((i + j) % 256); } ins.Parameters["@pic"].Value = data; ins.ExecuteNonQuery(); } con.Close(); } public static void CheckOne(int id, int picsize) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand sel = new MySqlCommand("SELECT pic FROM pics WHERE id = " + id, con); byte[] data = (byte[])sel.ExecuteScalar(); if(data.Length != picsize) { Console.WriteLine("picture #" + id + " corrupted"); } for(int j = 0; j < data.Length; j++) { if(((id + j) % 256) != data[j]) { Console.WriteLine("picture #" + id + " corrupted"); } } con.Close(); } public static void DropTable() { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand drp = new MySqlCommand("DROP TABLE pics", con); drp.ExecuteNonQuery(); con.Close(); } public static void CheckN(int n, int npics, int picsize) { Random rng = new Random(); for(int i = 0; i < n; i++) { int id = rng.Next(npics); CheckOne(id, picsize); } } public static void CheckTest(int nthreads, int npics, int picsize) { long t1 = DateTime.Now.Ticks; PicTestThread[] ptt = new PicTestThread[nthreads]; Thread[] thr = new Thread[nthreads]; for(int i = 0; i < thr.Length; i++) { ptt[i] = new PicTestThread(N/nthreads, npics, picsize); thr[i] = new Thread(new ThreadStart(ptt[i].Run)); } for(int i = 0; i < thr.Length; i++) { thr[i].Start(); } for(int i = 0; i < thr.Length; i++) { thr[i].Join(); } long t2 = DateTime.Now.Ticks; Console.WriteLine(nthreads + " conc reqs, " + npics + " pics in db, " + picsize/1000 + " KB pics => " + N/((t2 - t1) / 1000000.0) + " pics/sec"); } public static void Main(string[] args) { int[] npics = { 250, 500, 1000 }; int[] picsize = { 50000 /*, 100000, 200000 */ }; int[] nthreads = { 10, 20, 40 }; for(int i = 0; i < npics.Length; i++) { for(int j = 0; j < picsize.Length; j++) { CreateTable(npics[i], picsize[j]); for(int k = 0; k < nthreads.Length; k++) { CheckTest(nthreads[k], npics[i], picsize[j]); } DropTable(); } } } }
chrede>> jeg har selv bakset med billeder i databasen (via PHP) og jeg syntes nu ikke der var mærkbar performence ændring i forhold til når filerne ligger i en mappe - det der er afgørende for performencen - tror jeg - er størrelsen på dine billeder - ikke om det er en DB eller en mappe.
using System; using System.Threading; using System.Data; using ByteFX.Data.MySqlClient;
namespace E8 { public class PicTestThread { private int n; private int npics; private int picsize; public PicTestThread(int n, int npics, int picsize) { this.n = n; this.npics = npics; this.picsize = picsize; } public void Run() { PicTest.CheckN(n, npics, picsize); } }
public class PicTest { private const int N = 10000; public static void CreateTable(int npics, int picsize) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand cre = new MySqlCommand("CREATE TABLE pics (id INTEGER PRIMARY KEY, pic MEDIUMBLOB)", con); cre.ExecuteNonQuery(); MySqlCommand ins = new MySqlCommand("INSERT INTO pics VALUES (@id, @pic)", con); ins.Parameters.Add("@id", MySqlDbType.Int); ins.Parameters.Add("@pic", MySqlDbType.MediumBlob); for(int i = 0; i < npics; i++) { ins.Parameters["@id"].Value = i; byte[] data = new Byte[picsize]; for(int j = 0; j < picsize; j++) { data[j] = (byte)((i + j) % 256); } ins.Parameters["@pic"].Value = data; ins.ExecuteNonQuery(); } con.Close(); } public static void CheckOne(int id, int picsize) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand sel = new MySqlCommand("SELECT pic FROM pics WHERE id = " + id, con); byte[] data = (byte[])sel.ExecuteScalar(); if(data.Length != picsize) { Console.WriteLine("picture #" + id + " corrupted"); } for(int j = 0; j < data.Length; j++) { if(((id + j) % 256) != data[j]) { Console.WriteLine("picture #" + id + " corrupted"); } } con.Close(); } public static void DropTable() { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand drp = new MySqlCommand("DROP TABLE pics", con); drp.ExecuteNonQuery(); con.Close(); } public static void CheckN(int n, int npics, int picsize) { Random rng = new Random(); for(int i = 0; i < n; i++) { int id = rng.Next(npics); CheckOne(id, picsize); } } public static string CheckTest(int nthreads, int npics, int picsize) { long t1 = DateTime.Now.Ticks; PicTestThread[] ptt = new PicTestThread[nthreads]; Thread[] thr = new Thread[nthreads]; for(int i = 0; i < thr.Length; i++) { ptt[i] = new PicTestThread(N/nthreads, npics, picsize); thr[i] = new Thread(new ThreadStart(ptt[i].Run)); } for(int i = 0; i < thr.Length; i++) { thr[i].Start(); } for(int i = 0; i < thr.Length; i++) { thr[i].Join(); } long t2 = DateTime.Now.Ticks; return (nthreads + " conc reqs, " + npics + " pics in db, " + picsize/1000 + " KB pics => " + N/((t2 - t1) / 1000000.0) + " pics/sec"); } } }
Ja. Jeg holder mig til filer, indtil jeg får min egen web/db server op og køre...
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.